I have a table in my HTML file and in one of the columns I have a button component from bootstrap, when the button is clicked a drop down appears with three options - 'medium', 'low', 'servicerequest'. When this item is clicked, I am trying to get the value of the item clicked.
$(".table table-hover table-condensed").on('click', '.dropdown-menu', function(e) {
var id = $(this).attr('#mediumpriority');
alert(id);
});
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<table class="table table-hover table-condensed">
<thead>
<tr>
<th>Priority</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="btn-group">
<button type="button" class="btn btn-danger btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
High
</button>
<div class="dropdown-menu">
<a id="mediumpriority" class="dropdown-item">Medium</a>
<a class="dropdown-item">Low</a>
<a class="dropdown-item">Service Request</a>
</div>
</div>
</td>
</tr>
</tbody>
</table>
When I click on 'High' button, I get a drop down of three options, if i click on 'Medium' I expect an alert to show the the 'Medium' value:
<a id="mediumpriority" class="dropdown-item">Medium</a>
Can someone point out why I am not getting this alert when I run and click on the priority 'medium' ?