How can I access a specific child of a specific class?

In my div I have a child div of class "someClass". I want to access this child by class name, not id.

EDIT: Only in this particular div, not all other divs with the same class

0


a source to share


4 answers


var childOfNamedDiv = $('#namedDiv>.someClass')

      



+4


a source


var div = $('.someClass');

      



See jQuery Selectors .

+1


a source


just use a class selector:

$('div>.someClass').toggle()

      

+1


a source


if you already have a reference to the jquery object that is the parent of the div you want to find:

var parent = $("#someDiv"); // this is the div that you may alread have found earlier
var child = parent.children(".someClass");

      

+1


a source







All Articles