javascript - On a target page with multiple id's, script is acting only on the first one -
i'm filling in text box using greasemonkey. it's working, page has more 1 <input>
same id, , gm filling in first one.
the page's html (repeated 3 times):
<input type="text" id="se" value="" class="form">
gm code:
document.getelementbyid("se").value = "na";
how can set 2nd or 3rd <input>
too?
yeah, pages malformed html right pain. fortunately, queryselectorall()
works 1 hope on such pages. (alas, libraries, jquery, don't handle malformed pages well.)
in case, following code should work you:
var badinputs = document.queryselectorall ("#se"); (var j = badinputs.length - 1; j >= 0; --j) { var tinput = badinputs[j]; tinput.value = "na"; }
Comments
Post a Comment