javascript - Jquery - Accessing nested child elements -



javascript - Jquery - Accessing nested child elements -

assume have next html -

<div id="parentdiv"> <div id="subdiv1"></div> <div id="subdiv2"> <input id="input"> </div> </div>

to access input element using jquery, $("#input"). i'm trying access it, assuming know id of top level div.

currently have

$($($("#parentdiv").children()[1]).children()[0])

which seem work. there cleaner way of writing this, or way doing ok?

you perform .find() implicitly or explicitly:

$('#parentdiv input'); // implicitly $('#parentdiv').find('input'); // explicitly

reference: .find()

javascript jquery

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -