开发者

JQUERY -- Finding text wrapped in a SPAN, and outputting that to a <UL> as <LI>s

开发者 https://www.devze.com 2022-12-22 09:23 出处:网络
I have a large body o开发者_如何学JAVAf text which has several sentences wrapped in yada I\'d like to find a way with JQUERY, to go through the entire body of text, and every time it find a span with

I have a large body o开发者_如何学JAVAf text which has several sentences wrapped in yada

I'd like to find a way with JQUERY, to go through the entire body of text, and every time it find a span with class "findme", to take what ever copy is contianed between the tag and to append that to a UL as a LI

Ideas on how to do this efficiently?

THanks


Simplest way to do this is using each():

$("span.findme").each(function() {
  $("<li>").text($(this).text()).appendTo("ul");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消