Reputation: 555
Below is my code, my goal is when the user clicks the button with a class named click_me
, I want to alert the content inside the class named content
. I've tried doing:
JS:
alert($(this).closest('.content').html());
But it didn't work.
HTML:
<tr>
<div class="content">Hello</div>
<div>
<div>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
<ul>
<li><input type="button" class="click_me" value="Click Me"/></li>
<li></li>
</ul>
</div>
</div>
</tr>
Upvotes: 0
Views: 82
Reputation: 7429
$(function(){
$(".click_me").on("click",function(){
alert($(".content").html());
});
})
Upvotes: 0