article

Tuesday, July 21, 2015

Disable odd checkbox of Checkbox list using jQuery

Disable odd checkbox of Checkbox list using jQuery
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Disable odd checkbox of Checkbox list using jQuery</title>
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
  <style type='text/css'>
    body {
    font-family: Calibri;
    font-size : 12pt;
    padding :10px;
}
  </style>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
$(document).ready(function () {
    $("input[name='tech']").filter(':even').attr('disabled', true);
    $("input[name='hobbies']").filter(':odd').attr('disabled', true);
});
});//]]>  

</script>
</head>
<body>
  <b>1st Checkbox List: </b>
<br/>
<input type="checkbox" name="tech" value="jQuery" />jQuery
<br/>
<input type="checkbox" name="tech" value="JavaScript" />JavaScript
<br/>
<input type="checkbox" name="tech" value="Prototype" />Prototype
<br/>
<input type="checkbox" name="tech" value="Dojo" />Dojo
<br/>
<input type="checkbox" name="tech" value="Mootools" />Mootools
<br/>
<br/>
<b>2nd Checkbox List: </b>
<br/>
<input type="checkbox" name="hobbies" value="Sports" />Sports
<br/>
<input type="checkbox" name="hobbies" value="Racing" />Racing
<br/>
<input type="checkbox" name="hobbies" value="Singing" />Singing
<br/>
<input type="checkbox" name="hobbies" value="Writing" />Writing
<br/>
<input type="checkbox" name="hobbies" value="Travelling" />Travelling
<br/>
<input type="checkbox" name="hobbies" value="Cooking" />Cooking
<br/>
</body>
</html>

Related Post