How to checkbox?

-1

I wanted to know which Javascript command I can run on the site to mark the image box without clicking on it.

Do I need to know about the box html?

Before:

Then

    
asked by anonymous 14.02.2016 / 23:11

1 answer

1

If you refer to a checkbox, you can do it as follows:

HTML example:

<form action="">
<input type="checkbox" id="my_checkbox" value="Bike">Checkbox<br>
</form>

JavaScript:

var myCheckbox = document.getElementById('my_checkbox');
myCheckbox.checked = true;

Accessing within an iframe:

var myFrame = document.getElementById('my_frame');
var myCheckbox = myFrame.contentDocument.getElementById('my_checkbox');
myCheckbox.checked = true;
    
14.02.2016 / 23:25