Set checkbox checked jquery
- how to set checkbox value in javascript
- how to check checkbox value in javascript
- how to add checkbox value in javascript
- how to make checkbox checked in javascript
Html checkbox value=1 or 0...
How to Check/Uncheck the checkbox using JavaScript ?
In this article, we will learnhow to check/uncheck the checkbox using JavaScript.
Check if checkbox is checked javascript
As we know checkboxes are used to choose more than one value at a time so we can create a function to check more than one checkbox at a time.
We can check/uncheck the checkbox in following 2 ways:
Approach 1:Using the onclick event
To check and uncheck using the onclick event we define a function named checkAll that targets all the checkboxes using class.
Call this function when the onclick event is triggered as shown in the below example.
Example: This example demonstrates checking all the checkboxes with onclick event using a function to target all the checkbox inputs using class.
Output:
Approach 2: Using window.onload function
To check and uncheck using the window.onload we define a function named checkAll that targets all the checkboxes using class.
The checkAll function will be called when the contenet start loading on the webpage.
Example:
Output:
- how to check checkbox checked in javascript
- how to set multiple checkbox checked in javascript