html - jquery remove a element if not text is after it -
i'm having real hard time on trying understand how remove element when no text found after it
example html
<ul> <li>keep text <a>keep text</a> </li> <li>keep text <a>keep text</a> </li> <b class="warning">comments:</b> </ul> <ul> <li>keep text <a>keep text</a> </li> <li>keep text <a>keep text</a> </li> <b class="warning">comments:</b>keep b.warning element if text appears after </ul>
i , when no text found after the b.warning
<ul> <li>keep text <a>keep text</a> </li> <li>keep text <a>keep text</a> </li> </ul> <ul> <li>keep text <a>keep text</a> </li> <li>keep text <a>keep text</a> </li> <b class="warning">comments:</b>keep b.warning element if text appears after </ul>
just use row:
if($('b')[0].nextsibling) { $('b')[0].nextsibling.nodevalue = ''; $('b.warning').hide(); }
and here working fiddle:
http://jsfiddle.net/cfgr9/532/
thanks @nnnnnn , @samuel in comments.
Comments
Post a Comment