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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -