Find closest previous element jQuery

前端 未结 5 528
一向
一向 2020-12-14 06:33

I am wanting something similar to this person, except the element I want to match might not be a direct sibling.

If I had this HTML, for example,

<         


        
5条回答
  •  温柔的废话
    2020-12-14 06:50

    see http://api.jquery.com/prev/

    var link = $("#me").parent("div").prev("h3").find("b");
    alert(link.text());
    

    see http://jsfiddle.net/gBwLq/

提交回复
热议问题