Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一堆看起来像这样的 li:
<li class="thing">thing</li>
我想以某种方式thing变成<a href="#" class="remove-thing">thing</a>
thing
<a href="#" class="remove-thing">thing</a>
我在搞乱replaceWith,但是用标签而不是文本替换li整个a。有什么建议么?
li
a
您可以使用wrapInner()将列表项的内部文本包装在锚点中:
wrapInner()
$('.thing').wrapInner('<a href="#" class="remove-thing"></a>');
小提琴