Reputation: 13
<label class="" for="option1">
<input title="Select All" type="checkbox" id="option1" value="Select All" />
Select All
</label>
Now I want to get the id of input using value or label text="Select All" by using Jquery. Help me sort out Thanks in advance.
Upvotes: 0
Views: 90
Reputation: 30739
Use attribute selector $('[title="Select All]"]')
:
$(document).ready(function(){
var id = $('[title="Select All"]').attr('id');
console.log(id);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="" for="option1">
<input title="Select All" type="checkbox" id="option1" value="Select All" />
Select All
</label>
Upvotes: 3