javascript - How to remove a div if it contains a certain string in it? -
There is a list of items on one page, some are blank, with an example:
< Code> & lt; Div class = "item item" & gt; & Lt; Div class = "tophead" & gt; & Lt; Div class = "itemnumber" & gt; 30 & lt; / Div & gt; & Lt; One class = "article" href = "" & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; Div square = "foothills" & gt; & Lt; One class = "userlink" rel = "" & gt; & Lt; / A & gt; First & amp; Nbsp; & Nbsp; & Nbsp; & Lt; A href = "/ item? Id =" & gt; Discuss & lt; / A & gt; & Lt; / Div & gt;
Therefore, an example of jQuery or Javascript can be used to find: & lt; A class = "article" href = "" & gt; Remove any
class = item
of div
in any example of div class = item
on the page, and then Hide> which is the piece of code?
Updated reply: In the comments based on the explanation, instead Try it:
$ ('div.item: is (a.article [href = ""])'). Remove ();
Or it should also work:
$ ('div.item: has (a.article: not ([href])') . Remove ();
Or if you have problems with any of these, try:
$ ('div.item a.article'). Filter (function () {Return $ .trim (this.inner html) == '';}) Closest ('div.item'). Remove ();
Pre> $ ('Div.item: a.article ()') to delete ();. << Code> It will select
with and one whose Remove the elements with descendants and code> element class articles
and delete them. Of course, you can use .hide ()
instead if you can:
$ ('div.item: is ( A.article) '). Hide (); If you really mean that you only want a To delete the original guardian
of the article, you will do so: $ ('div.item: has (& gt; a. Article) '). Remove ();
This will remove the parent of a.article
instead of the .emem
class. It was not sure what you meant.
Comments
Post a Comment