Get all input fields inside div (without JS library)

apparat picture apparat · Aug 27, 2010 · Viewed 51.4k times · Source

What's the easiest way to get all input fields inside a div without using a javascript library like jQuery? Similar to this jQuery snippet:

var inputs = $('#mydiv :input');

Answer

Roy Sharon picture Roy Sharon · Aug 27, 2010
document.getElementById('mydiv').getElementsByTagName('input')