jquery shorthand for find() statement -


i have super simple question, instead of doing this:

$(".one").click(function() {     $(this).find('.two').find('.three').css... }); 

with html:

<div class="one">   <div class="two">     <div class="three"></div>   </div> </div> 

is there short hand can skip word find in way?

$('#one #two #three') 

but remember id in page supposed unique

so $('#three').css() should sufficient

it makes sense when elements either class elements or tagnames

$('.one .two .three') <-- $('div span p')       <--  these fine 

all these should work

// using find target class $(this).find('.two').find('.three').css('border', '1px dashed red'); // using find target class $(this).find('.two .three').css('border', '1px dashed red'); // using context $('.two .three',this).css('border', '1px dashed red'); // using context , immediate children $('> .two > .three',this).css('border', '1px dashed red'); 

> immediate children . other 2 using this context

check fiddle


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -