Possible Duplicate:
Select All Checkbox
I have the follow code for a Check All button that will check all my checkboxes on my webpage, but it's not working. Where is the function supposed to go? Because I've tried putting the code on my page but it doesn't work.
http://jsfiddl开发者_JAVA百科e.net/KbkZk/1/
Sorry lol, been a long day!!
What code? Generally you put your JS in the <head>
block of your page. If the JS will be manipulating the page's contents, you'll need to delay its execution until the rest of the page is loaded. In jquery, you do that with:
<script>
$(document).ready(function() {
... your code here ...
}):
</script>
If you're not using a JS library, you can do mostly the same thing with:
<body onload="myFunction();">
and have that myFunction do your initialization/setup.
精彩评论