Reputation: 956
Perhaps I'm just dense, but I can't work out how to get the div object with the id "getThisId" when "Option 2" is clicked in the btn-group div:
<div class="panel panel-primary">
<!-- Here's the div element I want to get when "option 2" is clicked -->
<div class="panel-body" id="getThisId">
<div class="itemHeading">sub-heading...</div>
Text...
</div>
<div class="panel-footer">
<div class="btn-group">
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">Button text... <span class="caret"></span></button>
<ul class="pull-right dropdown-menu" role="menu">
<li><a href="#">Option 1</a></li>
<li class="divider"></li>
<!-- Get the div with id "getThisId" when this is clicked -->
<li><a href="#" class="confirm_test">Option 2</a></li>
</ul>
</div>
</div>
</div>
</div>
I've tried various iteration of $(this).parent.prev and $(this).closest etc but nothing seems to work.
Upvotes: 0
Views: 546
Reputation: 10880
since it is an id, just do a $('#getThisId');
otherwise $(this).closest('.panel-footer').prev().find('#getThisId');
Upvotes: 1