Get checkbox with specific value with Jquery

Requirement – To get checkbox with specific value with jquery and mark it as checked.

if you have lots of check boxes on page and wanted to do something with specific checkbox, suppose in our example code below you wanted make below checkbox with value ‘ghi’ as checked.

<input type="checkbox"  value="abc"/>
<input type="checkbox"  value="def"/>
<input type="checkbox"  value="ghi"/>
<input type="checkbox"  value="jkl"/>
<input type="checkbox"  value="mno"/>

BELOW JQUERY CAN BE USED

$(document).ready(function(){
$("input[type=checkbox][value=ghi]").prop("checked",true);
OR
$(":checkbox[value=ghi]").prop("checked","true"); // this is alternate way to get that checkbox.
 });

Hope this helps… Happy Coding..!!!

(Visited 5 times, 1 visits today)