Find the number of <input> in an Div tag
html, javascript, xhtml
Solution
Why always the jquery solutions ? There is nothing wrong with using jquery, but including a JS library to count some elements is serious overkill.
Native javascript:
var inputCount = document.getElementById('divId').getElementsByTagName('input').length;
Problem
I need to find out the number `<input>` tag within a `<Div>` tag.. How it's possible.. For example the code will be like this.. ``` <div><li ><a>Jayan</a><input type="checkbox" id="c21" onClick="fcheck(this);" ></li> <li ><a href="#">Reshaba</a><input type="checkbox" id="c22" onClick="fcheck(this);" > <ul> <li ><a>crescent</a><input type="checkbox" id="c221" onClick="fcheck(this);" ></li> <li ><a>crescent</a><input type="checkbox" id="c222" onClick="fcheck(this);" ></li> <li ><a>crescent</a><input type="checkbox" id="c223" onClick="fcheck(this);" ></li> <li ><a>crescent</a><input type="checkbox" id="c224" onClick="fcheck(this);" ></li> </ul> </li></div> ``` Please help Thanks, Praveen J