• 0
  • 0

Jquery操作

2019-05-13 713 0 admin 所属分类:Javascript

ajax请求同步

$.ajaxSetup({
    async: false
});

JQ滑动到页面底部

var scrollHeight = $('html').prop("scrollHeight");
// $('html').scrollTop(scrollHeight,10);
$('html').animate({
    scrollTop: scrollHeight
}, 800);

防止滚动时窗口抖动

//当前滚动条的高度
var p=0;
$(window).scroll(function(){
   var temp_p = $(this).scrollTop();

   if (temp_p-p<0) {
      //向上滚动
      if ($('html').is(":animated")){
         $('html').stop();
         p=0;
         return false;
      }
   }
   p = temp_p;
});


删除DOM树同级后面的同胞元素

$(selector).nextAll().remove();

事件绑定,支持动态创建元素的监听

$(".content").on('dblclick', '.cell', function(e) {
    console.log(e);
});


返回顶部