jquery - how get text after br and wrap it in a div -


i have code:

<td class="tabledata">  <img>  <span class="someclass"></span>  <br>  text </td> 

i want text , wrap in div , give class name.

so far i've tried

$(".tabledata").html().split("<br />")[1];  $(".tabledata").each(function() {     $(this).nextall("br").get(0).wrap('<div></div>') }); 

any ideeas?

try

$($(".tabledata").children('br').get(0).nextsibling).wrap('<div />'); 

demo: fiddle

if want wrap direct text nodes children of td then

$(".tabledata").contents().filter(function(){     return this.nodetype == 3 && $.trim($(this).text()) != ''; }).wrap('<div />'); 

demo: fiddle


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -