Check if element contains another one in jQuery -


I found many related things on stack overflow but are not applicable to my case.

For all this example, I need to see that there is an element in another element, and if yes, then add something.

  $ (".bt_repondre"). Click (function () {comment = $ (this) Parent (). Parent (). (); // I want to comment whether the comment should be a .comment_full element, if not, Attach the comment .append ('add');});   

Hope you can help me, I tried many things ...

just use the .find () and check whether the element returns, such as:

  $ (".bt_repondre" ). Click (function () {Comment = $ (this) .Parent () .Parent (); if (! Comment.find ('. Comment_full') length) {comment.append ('add'); }});    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -