jquery - get elements by tag within a specific div?

newbie-shame picture newbie-shame · Dec 14, 2010 · Viewed 33.6k times · Source

I'm trying to get all input elements within a certain div, but it seems to return all inputs on any given page... is there a way to do this?

if($('#umi-form')) {
          var inputs = document.getElementsByTagName('input');
}

Answer

treeface picture treeface · Dec 14, 2010

It can be done like this:

var $inputs = $('#umi-form input');