Search code examples
javascript

get all the elements of a particular form


function getInputElements() {
    var inputs = document.getElementsByTagName("input");
}

The above code gets all the input elements on a page which has more than one form. How do I get the input elements of a particular form using plain JavaScript?


Solution

  • document.forms["form_name"].getElementsByTagName("input");