BatmanGirl
BatmanGirl

Reputation: 23

Javascript: How to replace document.all in this case?

In HTML:

<td><input type="checkbox" name="checkAll" onClick="doConfirmCheckAll()"></td> 

...and in JS:

document.all.checkAll.checked = false;

I have to replace the construct with something with the same meaning but I cannot use document.all (e.g. because of unsupport in IE11).

What should I use? Is document.getElementsByTagName("*").checkAll.checked a good idea?

Upvotes: 1

Views: 1919

Answers (1)

Bergi
Bergi

Reputation: 665276

If checkAll is a name attribute, you'd use

document.getElementsByName("checkAll")[0].checked = false;

If checkAll is an id attribute, you'd use

document.getElementById("checkAll").checked = false;

Upvotes: 1

Related Questions