I have a need to find and manipulate <input type="checkbox"> from a table. At the moment I have a very spartan function:
function testAjaxCheckBoxes() {
var table = document.getElementById("ajax_output");
var nodeList = table.getElementsByTagName("input");
}
That is all I know how to do at the moment. I have a nodeList object of all tags of <input>, but I don't know how to check each one's type or attributes.
I suppose the more general question is how do you view and manipulate attributes of any kind through DOM?
If you have the luxury of targeting Firefox >=3.5 and IE >=8, you can use
document.querySelectorAll("input[type=file]")
to get an array of DOM elements as desired. See more at the MDC documentation.
Once you have an element, you can use the getAttribute, setAttribute, and removeAttribute methods to read, write, and remove attributes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With