I want to know if the code below removes all input type='text' values back to "":
var inp = document.getElementsByTagName('input');
for (var i = inp.length - 1; i >= 0; i--) {
if ('text' === inp[i].type) inp[i].value = "";
}
Then I want to know if I have an input which is type='text' but which class is .num_questions. How can I code that so that it looks for the class name and gives it a value of "1"?
Well, i don’t think your question should be downvoted, handling classNames is not easy in javascript. So here is my answer: