Using jquery to find out the value on a clicked event. Each time the delete class is clicked the hiddenvariable returns the first hdid instead of the clicked hdid. When I use the this it returns the entire delete class but I only need the ‘hdid’ of the select class. The question is how can I use this to set the variable to the selected hdid
<form id="frmDelete" method="post" action="delete-class.php">
<ul id="class">
<li>
<div class="delete">ED 123-123<input type="hidden" name="hdid" id="hdid" value="6"/></div>
</li>
<li>
<div class="delete">EDU 121-101<input type="hidden" name="hdid" id="hdid" value="7"/></div>
</li>
<li>
<div class="delete">STU 120-456<input type="hidden" name="hdid" id="hdid" value="8"/></div>
</li>
</ul>
</form>
</div>
<script>
$(function() {
$(".delete").click(function() {
var hidden = $('#hdid').val();
console.log(hidden);
console.log(this);
});
});
</script>
And id should be unique