tags:

views:

94

answers:

2

hi,

I have a div as below:

<div id="DivInteractive">
     <p><strong>INTERACTIVE ONLINE BROCHURE</strong></p>
     <ul>
                  <li><a href="" target="_blank"/></li>
                        <li><a href="http://www.espireinfo.com" target="_blank">Internship brochure Interactive 2008</a></li>
                        <li><a href="http://www.google.com" target="_blank">OPUS EU Flyer Interactive 2009</a></li>
                        <li><a href="http://www.rai.com" target="_blank">2009 PLI Interactive Brochure</a></li>
                        <li><a href="http://cmsstag/index.aspx" target="_blank">Worldwide brochure Interactive English 2009</a></li>
                </ul>
</div>

Now I want to remove the li if there is no href coming from above div through jquery in above case when page will be loaded, it will remove the first li and my output will be as given below:

<div id="DivInteractive">
         <p><strong>INTERACTIVE ONLINE BROCHURE</strong></p>
         <ul>

                            <li><a href="http://www.espireinfo.com" target="_blank">Internship brochure Interactive 2008</a></li>
                            <li><a href="http://www.google.com" target="_blank">OPUS EU Flyer Interactive 2009</a></li>
                            <li><a href="http://www.rai.com" target="_blank">2009 PLI Interactive Brochure</a></li>
                            <li><a href="http://cmsstag/index.aspx" target="_blank">Worldwide brochure Interactive English 2009</a></li>
                    </ul>
    </div>

Please suggest any solution using jquery

+2  A: 

Does this work?

$("#DivInteractive li:has(a[href=''])").remove();
cletus
I want to remove only for the div id="DivInteractive" not for all
MKS
Its not working as in my page it is coming down to page. I think i need to check in complete page.
MKS
it may be the function .remove() it is not working
MKS
This code is working on my local machine and in the Google AJAX APIs Playground. Which version of jQuery are you running?
Doomspork
A: 

I'm not so great with regex, but to add to Cletus' answer, I would do:

$("#DivInteractive li:has(a[href='regex(check for on or more spaces)'])").remove();

This way, it would remove it if the href was set to "" or " " or whatever.

idrumgood