jQuery: Find previous element with class

前端 未结 4 416
生来不讨喜
生来不讨喜 2020-12-17 10:22

I have a really simple problem.

How can I find the first previous element of another element? I tried the code below without success.

HTML:

&         


        
4条回答
  •  误落风尘
    2020-12-17 11:03

    Try this:

    $('.C').click(function() {
    
            alert($(this).parent().prev('.A').html());
    
    });
    

提交回复
热议问题