<div>Zero-th <span></span></div> <div>First <span></span></div> <div>Second <span></span></div> <script> $("div").attr("id", function (arr) { return "div-id" + arr; }).each(function () { $("span", this).html("(ID = '<b>" + this.id + "</b>')"); }); /*//下面这种写法和上main写法一样 $("div").attr("id", function (arr) { return "div-id" + arr; }).each(function () { $(this).find('span').html("(ID = '<b>" + this.id + "</b>')"); }); */ </script>也即是:$('span',this)相当于$(this).find($('span'))
$('span',this)
最新推荐文章于 2022-11-23 11:57:35 发布