skip to Main Content

I want to hide all div that had href find bellow exactly the div that I want to hide

<div style="margin-left:36.847599164927%;margin-top:-30.27139874739%;width:19.72860125261%"><a href="//www.exemple.com/item/detail/4000105891117.html" target="_blank" rel="noopener"><img src="//ae01.alicdn.com/kf/He3f2750635b24a4d9e30666180dfacc89.png"></a></div>

I want also hide the dive with image that had the structure below

<div><img src="//ae01.alicdn.com/kf/Haabbc1065ea449668ced4bf88021f4aea.png"><p></p>

here is the big text that I want to hide the talked div above from it , and keep all other div

<div class="woocommerce-Tabs-panel woocommerce-Tabs-panel--description panel entry-content wc-tab" id="tab-description" role="tabpanel" aria-labelledby="tab-title-description" style="">
                
    <h2>Description</h2>

<div>
<div>
<div>
<div><img src="//ae01.alicdn.com/kf/Haabbc1065ea449668ced4bf88021f4aea.png"><p></p>
<div style="margin-left:36.847599164927%;margin-top:-30.27139874739%;width:19.72860125261%"><a href="//www.exemple.com/item/detail/4000105891117.html" target="_blank" rel="noopener"><img src="//ae01.alicdn.com/kf/He3f2750635b24a4d9e30666180dfacc89.png"></a></div>
<div style="margin-left:57.306889352818%;margin-top:-29.958246346555%;width:19.72860125261%"><a href="//www.exemple.com/item/detail/4000147845779.html" target="_blank" rel="noopener"><img src="//ae01.alicdn.com/kf/He3f2750635b24a4d9e30666180dfacc89.png"></a></div>
<div style="margin-left:77.76617954071%;margin-top:-29.958246346555%;width:19.72860125261%"><a href="//www.exemple.com/item/detail/4000990281325.html" target="_blank" rel="noopener"><img src="//ae01.alicdn.com/kf/He3f2750635b24a4d9e30666180dfacc89.png"></a></div>
<div style="margin-top:0.31315240083507%;height:0;width:0"></div>
</div>
<div><img src="//ae01.alicdn.com/kf/H69979517a8a248e9a84aec8986854e277.png"><p></p>
<div style="margin-left:1.5657620041754%;margin-top:-31.524008350731%;width:22.964509394572%"><a href="//www.exemple.com/item/detail/4000985761425.html" target="_blank" rel="noopener"><img src="//ae01.alicdn.com/kf/H6dac222274304fc4afe554f53ea88bcds.png"></a></div>
<div style="margin-left:26.096033402923%;margin-top:-30.793319415449%;width:22.964509394572%"><a href="//www.exemple.com/item/detail/4000224026872.html" target="_blank" rel="noopener"><img src="//ae01.alicdn.com/kf/H6dac222274304fc4afe554f53ea88bcds.png"></a></div>
<div style="margin-left:50.62630480167%;margin-top:-30.793319415449%;width:22.964509394572%"><a href="//www.exemple.com/item/detail/1005001597400364.html" target="_blank" rel="noopener"><img src="//ae01.alicdn.com/kf/H6dac222274304fc4afe554f53ea88bcds.png"></a></div>
<div style="margin-left:75.156576200418%;margin-top:-30.793319415449%;width:22.964509394572%"><a href="//www.exemple.com/item/detail/4001044974112.html" target="_blank" rel="noopener"><img src="//ae01.alicdn.com/kf/H6dac222274304fc4afe554f53ea88bcds.png"></a></div>
<div style="margin-top:0.73068893528184%;height:0;width:0"></div>
</div>
</div>
<div style="border:0"></div>
</div>
</div>
<div>
<div>
<div>
<div></div>
</div>
</div>
<div>
<div>
<div>
<div></div>
</div>
</div>
<div>
<div></div>
</div>
</div>
<div>
<div></div>
<p></p></div>
</div>
<div>
<div>
<div></div>
<div>
            <strong style="font-size: 12px"><span style="font-size: 18.0px">Q: Why are there dark chips?</span></strong>
        </div>
<div>
            <span style="color: #ffc000"><span style="font-size: 18.0px">  Those dark lights(</span></span> <span style="color: #ff0000"><span style="font-size: 18.0px">UV&amp;IR</span></span> <span style="color: #ffc000"><span style="font-size: 18.0px">) are normal, we have been professionally designed , this is not a defect of the product. They play an important role in the growth and development of plants.</span></span>
        </div>
<div>
            <strong style="font-family: times new roman , times , serif;color: #ff0000;font-size: 18.0px">(Do not accept open disputes for this reason)</strong>
        </div>
<p>
            <img src="//ae01.alicdn.com/kf/HTB11c63QCzqK1RjSZFHq6z3CpXaR.jpg"><strong style="font-size: 22px"><span style="font-family: times new roman , times , serif">Introductions</span></strong>
        </p>
<div>
            <strong><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Full Spectrum:</span></span></strong>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">The upgraded grow light was designed with full spectrum (47red+19blue+3UV+3IR+3White),give off perfect wavelength for all growing stage. Suitable for seeding,germination,vegetative &amp; flowering.</span></span>
        </div>
<div></div>
<div>
            <strong><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Easy set up:</span></span></strong>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Update hanging kit make this grow lamp much more easy to assenble. ABS plastic material body, excellent heat control LED chips helps ytour plants grow better.</span></span>
        </div>
<div>
            <strong><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Adjustable Coverage:</span></span></strong>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">The high-brightness growing lamp covers a maxmum of 1.2 x 3 ft at a height of 2 ft. It is recommended to hang about 8-30 inch from the top of plant, depending on the growth cycle.</span></span>
        </div>
<div></div>
<div>
            <strong><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Specifications:</span></span></strong>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Power: 25w/45W</span></span>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">LED Chip: 75Leds/144Leds</span></span>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Luminous Flux: 1000lm/1500lm</span></span>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Life time: 30,000 hours</span></span>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Material: ABS</span></span>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Input Voltage: 85-265V</span></span>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Dimension: 310 x 119 x 29.5mm/252 x 252 x 29.5mm</span></span>
        </div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Certification: RoHS CE FCC UL</span></span>
        </div>
<div>
            <span style="color: #ff0000"><strong><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">Package includes:</span></span></strong></span>
        </div>
<div>
            <span style="color: #ff0000"><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">1 x 25W /45W LED Grow Light</span></span></span>
        </div>
<div>
            <span style="color: #ff0000"><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">1 x Power Cord</span></span></span>
        </div>
<div>
            <span style="color: #ff0000"><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">1 x Steel hanging kits (with 4 ropes)</span></span></span>
        </div>
<div>
            <span style="color: #ff0000"><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif">1 x User Manual</span></span></span>
        </div>
<div></div>
<div></div>
<div>
            <span style="color: #000000"><strong style="font-family: times new roman , times , serif;color: #ff0000;font-size: 18.0px">———————————————————————-</strong></span>
        </div>
<div>
            <strong style="font-family: times new roman , times , serif;color: #ff0000;font-size: 18.0px"><span style="color: #000000"><span style="font-family: times new roman , times , serif"><span style="font-size: 36.0px">Satisfaction —— Give us 5 stars .</span></span></span></strong>
        </div>
<div>
            <font color="#000000" face="times new roman, times, serif"><span style="font-size: 36.0px"><b>Not satisfaction  —— Feel free to contact us.</b></span></font>
        </div>
<div>
            <strong style="font-family: times new roman , times , serif;color: #ff0000;font-size: 18.0px"><span style="color: #000000"><span style="font-family: times new roman , times , serif"><span style="font-size: 36.0px">  </span></span></span></strong>
        </div>
<p></p></div>
<div>
        <strong style="font-family: times new roman , times , serif;color: #ff0000;font-size: 18.0px"></strong></div>
</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div>
<div></div>
<div>
<div></div>
<div>
<div></div>
<div>
<div></div>
<div>
<div></div>
<div>
<div>
    </div>
<div>
<div>
            <strong style="font-family: times new roman , times , serif;color: #ff0000;font-size: 18.0px">                            </strong>
        </div>
<div>
            <span style="color: #ff0000"><span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif"><img src="//ae01.alicdn.com/kf/HTB1Bdv2X0jvK1RjSspiq6AEqXXak.jpg"><img src="//ae01.alicdn.com/kf/HTB1Q4z1XZfrK1RkSnb4q6xHRFXab.jpg"><img src="//ae01.alicdn.com/kf/HTB1XTP1X4rvK1RjSszeq6yObFXaX.jpg"><img src="//ae01.alicdn.com/kf/HTB1LID4X.zrK1RjSspmq6AOdFXaD.jpg"></span></span></span>
        </div>
<div></div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif"><img src="//ae01.alicdn.com/kf/HTB1ztyGJKGSBuNjSspbq6AiipXay.jpg"><img src="//ae01.alicdn.com/kf/HTB1rcc0mHArBKNjSZFLq6A_dVXaz.jpg"><img src="//ae01.alicdn.com/kf/HTB18GhrcO6guuRjy1Xdq6yAwpXah.jpg"><img src="//ae01.alicdn.com/kf/HTB1BIBrJ21TBuNjy0Fjq6yjyXXat.jpg"><img src="//ae01.alicdn.com/kf/HTB1oz.7czfguuRjSszcq6zb7FXab.jpg"><img src="//ae01.alicdn.com/kf/HTB1KLvuJH5YBuNjSspoq6zeNFXay.jpg"><img src="//ae01.alicdn.com/kf/HTB1A9RYmIUrBKNjSZPxq6x00pXad.jpg"><img src="//ae01.alicdn.com/kf/HTB1aRW1BBmWBuNkSndVq6AsApXaE.jpg"><img src="//ae01.alicdn.com/kf/HTB1TS4YmIUrBKNjSZPxq6x00pXao.jpg"><img src="//ae01.alicdn.com/kf/HTB1tBTrJL9TBuNjy0Fcq6zeiFXaX.jpg"><img src="//ae01.alicdn.com/kf/HTB1bElxdRcXBuNjt_biq6xpmpXae.jpg"><img src="//ae01.alicdn.com/kf/HTB1JZWtmUOWBKNjSZKzq6xfWFXaR.jpg"></span></span>
        </div>
<div></div>
<div></div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif"><img src="//ae01.alicdn.com/kf/HTB1bK4MmL6TBKNjSZJiq6zKVFXaq.jpg"></span></span>
        </div>
<div></div>
<div>
            <span style="color: #ffffff"><span style="font-size: 48.0px"><b><span style="background-color: #ffc000">             Most  Popular               </span></b></span></span>
        </div>
<div></div>
<div></div>
<div>
            <span style="font-size: 18.0px"><span style="font-family: times new roman , times , serif"><img src="//ae01.alicdn.com/kf/HTB1qgqOJ4TpK1RjSZR0q6zEwXXa3.jpg"></span></span>
        </div>
<div>
            <img src="//ae01.alicdn.com/kf/HTB1pDqOJVYqK1RjSZLeq6zXppXav.jpg" style="font-family: times new roman , times , serif;font-size: 18.0px">
        </div>
<div>
            <img src="//ae01.alicdn.com/kf/Hca2f2d644b0c4af6a2fa2a51eeef79425.jpg">
        </div>
<div>
<p>
                1, If the goods isn't received within Our on-time delivery, we will refund you.
            </p>
<p>
                2, If you haven't received your goods or if there is any problem when you receive the goods, please contact us first, please don't open dispute directly, if we can not solve the problemfor you, then you can open dispute. We will be highly appriciated.
            </p>
<p>
                3, It's the buyer's duty to clear cutoms and pay for import duties, taxes or charges, please pay attention to the tracking information closely and clear customs as soon as you can to avoid any delay in shipment.
            </p>
<p>
                4, When you place the order, please make sure your name, address, phone number are correct.
            </p>
<p>
                <img src="//ae01.alicdn.com/kf/H771da19fcd8f46708c67d4cbdda87ff16.jpg"><span style="font-family: Arial;font-size: 10.5pt;letter-spacing: 0pt;text-indent: 0pt">1, If the products have some problem, please send  a picture or video on youtube or on exemple to show the problem. Seller will offer partial or full refund according to the proof provided by the buyer.</span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">2, If the products has not been used and you want to return it, please send it back in 7 days or we will assume that the products  have been used.</span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial"><img src="//ae01.alicdn.com/kf/H998705c2b8c14db591dd6d2954678a3eR.jpg"></span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p></p></div>
<div>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">Q: How can I get a discount?</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">A: The prices showed in our store are the best price we could offer. It's the cheapest price you can get. However, if your order quantity is more than 10pcs(total quantity for one order), you may contact us before payment, we can probably save some shipping cost for you.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">For very big orders, of course we will offer some discount.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">Please follow below process to get the discount.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">1. Make an order first, do not pay immediately.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">2. Leave us a message to tell us the quantity and shipping method you want.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">3. We will change the amount for you as soon as possible.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">4. Send the payment.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial"> </span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">Q: What can I do if I haven't received the parcel for a long time?</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;line-height: 12.65pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">A: If the  tracking information shows left China mainland or Hong Kong,but no information on your local post office website, the parcel now is on the way to your country, or arrived at your country but no updated information received from your local post office yet, please be patient to wait.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p style="margin: 3.75pt 0pt;text-indent: 0pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">
                <span style="font-family: Arial;letter-spacing: 0pt;font-size: 10.5pt;background-image: initial;background-position: initial;background-size: initial;background-attachment: initial">If the protection time is less than 10 days but you still haven't got the parcel, please contact us, we will extend the protection time for you and try to  find the reason for delay and try to solve and tell you the latest information we got.</span><span style="font-family: sans-serif;letter-spacing: 0pt;font-size: 12pt"></span>
            </p>
<p></p></div>
<p>
            <img src="//ae01.alicdn.com/kf/Habfa77b420ac41caa3ed4ad94849e60b3.jpg">
        </p>
<p></p></div>
</div>
<p></p>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div style="border:1">
<div>
<div><img src="//ae01.alicdn.com/kf/Hedb6b70de894429f9c5a9bdf916083c3I.png"></div>
</div>
</div>
</div>
</div>
            </div>

I tried this java script code but it hides all the div

window.addEventListener=()=>{
var elem=document.querySelectorAll("div");
var i;
for(i=0;i<elem.length;i++){
  var obj=elem[i];
  if(obj.innerHTML.toString().includes('href')){
      obj.style.display="none";
    }
}
}

2

Answers


  1. I think you should be okay using the :has query: https://developer.mozilla.org/en-US/docs/Web/CSS/:has#Examples

    div:has(a[href]) {
        display: none;
    }
    

    Edit

    @Robbie JW True I forgot that CSS doesn’t support the :has query. So I think you’d have to either add a css class .has-a-href to the divs manually, or use javascript/JQuery. Since you’re using JQuery:

    $("div:has(a[href])").css("display", "none")
    

    Edit 2:

    Login or Signup to reply.
  2. Assuming you want to remove <div>s which have child elements which have a href attribute, this JavaScript would suffice:

        const divs = document.querySelectorAll("div");
        divs.forEach(div => {
            Array.from(div.children).forEach(child => {
                if (child.matches("a[href]")) {
                    div.style.display = "none";
                }
            })
        })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search