Jquery选择元素的方法

来源:互联网 发布:钟云龙徒弟知多少 编辑:程序博客网 时间:2024/04/28 08:01
.not() 从匹配元素集合中删除元素。
实例:lazyload延迟加载图片
jQuery(document).ready(function ($) {
    $("img").not("#js-comment-box img,.bottom_bottom img").lazyload({
        placeholder: "",
        effect: showeffect,
        threshold: 0,
        failurelimit: 10
    })
});

返回顶部
<div class="goTop"><a title="返回顶部" class="top" id="gotop_t" href="javascript:;"></a></div>
<script type="text/javascript">
$(document).ready(function () {
//当点击跳转链接后,回到页面顶部位置
$("#gotop_t").click(function () {
  $('body,html').animate({ scrollTop: 0 }, 500);
    return false;
  });
})
</script>

选择(#sortlist)下的最后一个(div)下的第一个(div),添加名为(current)的类
<script>
           $('#sortlist div:last-child').children("div:first-child").addClass('current')
</script>

移除(.banner)下(a)元素的(title)属性
<script>
           $(".banner").children("a").removeAttr("title")
</script>
0 0
原创粉丝点击