Link to home
Start Free TrialLog in
Avatar of earwig75
earwig75

asked on

How can I get elements in jQuery with parent/child

I am writing some javascript tests and I would like to do the below using jQuery, $('.parent .child'); can someone assist?

"has at least 1 entry after loadFeed function is called"

it(".feed container has at least 1 entry", function(done) { 
       var numEntries = document.querySelector(".feed").getElementsByClassName("entry").length;   //use jquery parent/child here
       expect(numEntries).toBeGreaterThan(0); 
       done(); 
     }); 

Open in new window

Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

$('element').parent() will give you the parent of an element.
$'('element').parent().children() will give you all the children of that parent element
$('element').siblings() will return all the children of the parent except this one.

Not really sure what you are asking?
ASKER CERTIFIED SOLUTION
Avatar of earwig75
earwig75

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of earwig75
earwig75

ASKER

Posted answer.