简体   繁体   English

从div删除jQuery时没有href时删除li

[英]Removing li when no href with jquery from div

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: 现在,如果要在上面的情况下在通过jQuery通过jQuery从div上方获取没有href的时候,我想删除li ,那么它将删除第一个li,我的输出如下所示:

<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 请提出任何使用jQuery的解决方案

这样行吗?

$("#DivInteractive li:has(a[href=''])").remove();

I'm not so great with regex, but to add to Cletus' answer, I would do: 我对正则表达式不太满意,但是要添加到Cletus的答案中,我会这样做:

$("#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. 这样,如果href设置为“”或“”或其他内容,它将删除它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM