2009-07-29 26 views
0

我有一個div如下:卸下李時使用jQuery沒有HREF從DIV

<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> 

現在我想刪除如果沒有HREF從上面的div未來通過jQuery的 在以上時,頁面會被加載時,它會刪除第一個麗和我的輸出將在下文中給出:

<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> 

使用jQuery

請提出解決方案

回答

2

這是行不通的嗎?

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

我想刪除只爲div id =「DivInteractive」並非全部 – 2009-07-29 15:07:23

+0

它不工作,因爲它在我的頁面,它正在下降到頁面。我想我需要檢查整個頁面。 – 2009-07-29 15:16:45

+0

它可能是函數.remove()它不起作用 – 2009-07-29 15:19:41

0

我不是正則表達式那麼大,但是添加到克萊圖斯的回答,我會做:

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

通過這種方式,它會刪除它,如果將href設置爲‘’或「」或其他。