javascript - Find closest div with specified class -
i have dom construction as
<div id="content"> <div id="wrapper"> <input type="text" id="search" /> </div> </div> <div class="subcontent"> </div> <div class="subcontent"> </div> i want select <div class="subcontent"> on come in event of input box closest input box.
$('#search').on('keypress', function(){ $(this).parent().parent().next(); }); is there improve way ?
$(this).closest('#wrapper').nextall('.subcontent').first()
that way can alter utilize classes
javascript jquery html
No comments:
Post a Comment