-1

I have a list of items with varying string length:

<li class="rtsLI">
<a class="rtsLink rtsAfter" title="Something">
<span class="rtsOut">
<span class="rtsIn">
<span class="rtsTxt">
Short list item here</span>
</span>
</span>
</a>

</li>
<li class="rtsLI">
<a class="rtsLink rtsAfter" title="Something Else">
<span class="rtsOut">
<span class="rtsIn">
<span class="rtsTxt">
Really really really long list item goes here drop this text below</span>
</span>
</span>
</a>

</li>
<li class="rtsLI">
<a class="rtsLink rtsAfter" title="Something Else As well">
<span class="rtsOut">
<span class="rtsIn">
<span class="rtsTxt">
I might want to add a line here drop this text below</span>
</span>
</span>
</a>

I would like to enter a line break into the text belonging to class "rtsTxt". So for example, the "drop this text below" would still be within the list item but a line below.

I've tried a few things with .contains and .replace but I can't seem to nail the so and so! Any lunchtime help, greatly appreciated.

The jsfiddle can be found here

4

1 回答 1

1
$('.rtsTxt').html(function(_,htm){
  return htm.split(',').join("</br>");
});

演示----> http://jsfiddle.net/gFwFR/9/

于 2013-06-24T12:02:32.473 回答