A bit confused about how to target the following input with name client id, Tried lots of things but nothing worked !
So here I am :
<td class="main_contact">
<input type="hidden" name="client_id" value="45">
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</td>
Here is what I tried as :
$('.switch input').on('change',function() {
if (this.checked) {
var parent_el = $(this).parents().eq(1).closest('input[name="client_id"]').val();
// var client_id = $(parent_el[0]+' input[name="client_id"]').val();
console.log(parent_el);
} else {
alert('Its UNCHECKED');
}
});
NOTE : I want to get the value of input with name client_id
while referencing it from the $(this)
element so that I get only the current changed element input data not the data of every input there is?