9、第九节课jquery选择器jq2,20151007

1、表单选择器

2、not 里面不能加其他标签

  $div p:not(not:disable)  错误的

  $div p:not(:disable)  正确的

3、选择设置相应属性的标签项

  $("img[title]");

  $("img[title]").eq[1];

4、获取所有DIV中设置title属性为‘你好’的div 索引

  $("div").index($("div[title='你好']"));

 5、title 属性为你好的第二个div 的索引

  $("div").index($("div[title='你好']").eq[1]);

6、鼠标定位

  $("div").click(function()

  {alert($(this).index());

  alert($(this).text); // 获取点击DIV 的内容

})

7、JQuery 链

  

8、遍历

  

    
 $("#btn").click(function () {
        $("div").each(function (index) {
            var i = index + 1;
            $(this).attr("title", "我是第" + i + "个div");
        }); 

9、获取属性只 attr

  $("div").eq(3).css("title","你好我是第四个");

原文地址:https://www.cnblogs.com/stonecoolboy/p/4859571.html