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
Post a Comment