[an error occurred while processing this directive]

JavaScript click method


In the html page we can select the check box either by clicking on the checkbox option while selecting any option or we can call the JavaScript method click() on the checkbox object. In this example we have developed an example which shows how one can select the checkbox by using the method click.



Description of code:

Here in this example html code we have create three check boxes and three buttons. In these three checkboxes we have called the three different functions selectFirst(), selectSecond(), selectThird().All these three methods calls the click method with the checkbox objects.

Here is the full example source code of clickExample.html as follows:

<script language="JavaScript">
        function selectFirst() {
        function selectSecond() {
        function selectThird() {
       <p align="center">&nbsp;</p>
       <div style="background: #cf2255; width:'100%';" align="center">
       <font color="#ffffcc" size="12pt"><b>Click Example</b></font></div>
       <p align="left">
       <input type="checkbox" id="checkbox1" value="Checkbox1">
       <button onclick="selectFirst();">Click first checkbox</button>
        <p align="left">
        <input type="checkbox" id="checkbox2" value="Checkbox1">
        <button onclick="selectSecond();">Click second checkbox</button>

        <p align="left">
        <input type="checkbox" id="checkbox3" value="Checkbox3">
        <button onclick="selectThird();">Click third checkbox</button>

Output :

Download Source Code


[an error occurred while processing this directive]