jquery - find previous div with class name rather than using parent().parent()....parent() -
<div class="a"> <span class = "s"> <button> <button> <div class="b"> <p> <textarea> <div> <button class="click"> </div> </div> </div>
on button click of class "click" . need find in div class a.
what tried
$('.click').parent().parent().parent().find('span') -- working
i looking similar alternative in easiest way
$('.click').closest('div').find('.a') -- not working $('.click').closest('div').prev('.a') -- not working
what correct approach when traversing inside multiple , find class name
* note : sample html find correct approach in jquery , not find syntax error in html
thanks
closest('.a')
should it. finds first element in element's ancestry (starting element , going parent, etc.) matching selector.
Comments
Post a Comment