Last active
August 24, 2017 03:27
-
-
Save mazfreelance/27c014a5760b734b9f075b7ea86802ce to your computer and use it in GitHub Desktop.
JQUERY: Check & Uncheck using selection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<SCRIPT language="javascript"> | |
$(document).ready(function() { | |
$("#check").change(function() { | |
var d = $(this).val(); | |
if(d == 'parent'){ | |
$(".child").prop("checked", !d.checked); | |
} | |
}); | |
$("#check").change(function() { | |
var d = $(this).val(); | |
if(d == 'parentnone'){ | |
$(".child").prop("checked", false); | |
} | |
}); | |
}); | |
</SCRIPT> | |
<select id="check"> | |
<option>Select</option> | |
<option value="parent" data-checked='false'>All</option> | |
<option value="parentnone" data-checked='false'> None </option> | |
</select> | |
<hr/> | |
<ul> | |
<li> | |
<input type="checkbox" class="child" /> Checkbox 1</li> | |
<li> | |
<input type="checkbox" class="child" /> Checkbox 2</li> | |
<li> | |
<input type="checkbox" class="child" /> Checkbox 3</li> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment