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
Comments
Post a Comment