zsharp
zsharp

Reputation: 13756

How to access specific div child of certain class?

In my div i have a child div of class "someClass". I want to access that child by classname, not id.

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

Upvotes: 0

Views: 1238

Answers (4)

Darko
Darko

Reputation: 38860

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

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

Upvotes: 1

Chris Farmer
Chris Farmer

Reputation: 25386

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

Upvotes: 4

user434917
user434917

Reputation:

just use the class selector:

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

Upvotes: 1

Sasha Chedygov
Sasha Chedygov

Reputation: 130777

var div = $('.someClass');

See jQuery Selectors.

Upvotes: 1

Related Questions