HTML 代码:
<p>Hello</p><p>cruel</p><p>World</p>
jQuery 代码:
$(“p”).slice(1).wrapInner(“<b></b>”);
结果:
[ <p><b>cruel</b></p>, <p><b>World</b></p> ]
Selects all paragraphs, then slices the selection to include only the third element.
HTML 代码:
<p>Hello</p><p>cruel</p><p>World</p>
jQuery 代码:
$(“p”).slice(-1).wrapInner(“<b></b>”);
结果:
[ <p><b>World</b></p> ]










