私信  •  关注

Ande Caleb

Ande Caleb 最近创建的主题
Ande Caleb 最近回复了
5 年前
回复了 Ande Caleb 创建的主题 » 如何使用jquery更改动画速度?

只是一个小代码,还没有测试过,但我希望它接近你想要的,使用 offset() 在滚动页面时检索顶部位置。。

并设置 xtop 变量,然后调用 doAnimation() 每次页面滚动时,请记住调用 stop() 方法,以便动画缓存不会提示系统的速度。

var xtop;

window.onScroll = function(){
    xtop = $(window).offset().top; //get the top position.
    doAnimation();
}

function doAnimation(){
   $(".test2").stop().animate({top: xtop}, 10000, "linear");  
}

xtop公司 位置在10秒(10000毫秒),我希望它能工作。

5 年前
回复了 Ande Caleb 创建的主题 » 表单验证完成后显示模态的Jquery代码

你可以在你的表格上。。。

<form id="myform" action=".." method=".." onsubmit="return validateForm(this);"> 
.....
</form>

现在假设您正在使用jquery表单验证插件

function validate(formObj){
  v = $(formObj).validate({ // initialize the plugin
        rules: {  //enter additional rules.
           input1: {required: true, email:true},   
           input2: {required: true, integer:true}
        },
        submitHandler: function(formObj) {
          $('#myform').removeAttr('onsubmit');   //remove the onsubmit attr..              
          $(modal).addClass('active');    //then show the modal here.. 

        }
      });
  return false; //which stops the form from submitting.. 
}

现在让我们假设模式已经弹出,用户已经接受了协议并单击了agree按钮,然后触发表单并发送它

function sendFromModal(){
  $('#myform').submit();
   return true; //
}