how to select / unselect the checkboxes using javascript/jquery
I have the following html code
html code
<p><a href="" onclick="select()">Select All</a> / <a href=""
onclick="unselect()" >Unselect All</a> </p>
{% for field in fields %}
<div class="contact_align">
<input id="select-unselect" type="checkbox" name="invite"
value="so">{{ field }}
</div>
{% endfor %}
<script type="text/javascript">
function select(){
$('#select-unselect').attr('checked',true);
}
function unselect(){
$('#select-unselect').attr('checked',false);
}
</script>
so above is my code, and the functionality is not working , so can anyone
please let me know what i am doing wrong in the above code and make it
work ?
No comments:
Post a Comment