六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 95|回复: 0

jquery 遍历 end()

[复制链接]

升级  67.33%

130

主题

130

主题

130

主题

举人

Rank: 3Rank: 3

积分
402
 楼主| 发表于 2013-2-7 21:22:21 | 显示全部楼层 |阅读模式
end()
恢复最近一次破坏性对匹配元素集合的操作,返回到之前的匹配元素集合状态。返回匹配元素集合
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                     "http://www.w3.org/TR/html4/loose.dtd"><html><head>  <script src="http://code.jquery.com/jquery-latest.js"></script>    <script>  $(document).ready(function(){        jQuery.fn.showTags = function (n) {      var tags = this.map(function () {                               return this.tagName;                             })                        .get().join(", ");      $("b:eq(" + n + ")").text(tags);      return this;    };    $("p").showTags(0)          .find("span")          .showTags(1)          .css("background", "yellow")          .end()          .showTags(2)          .css("font-style", "italic");  });  </script>  <style>  p, div { margin:1px; padding:1px; font-weight:bold;            font-size:16px; }  div { color:blue; }  b { color:red; }  </style></head><body>  <p>    Hi there <span>how</span> are you <span>doing</span>?  </p>  <p>    This <span>span</span> is one of     several <span>spans</span> in this    <span>sentence</span>.  </p>  <div>    Tags in jQuery object initially: <b></b>  </div>  <div>    Tags in jQuery object after find: <b></b>  </div>  <div>    Tags in jQuery object after end: <b></b>  </div></body></html> 
end()
将返回到执行find("span")操作之前的匹配元素集合状态
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表