javascript - Determin Type of Input - jQuery -


i needing determine type of element, possibly identified id property of it.

for example, in following form...

<form id='my-form'>   <input type='text' id='title' />   <textarea id='comment'></textarea> </form> 

i have way identify $('#title') text box.

after searches, tried thing this, returns undefined.

$('#title').type 

but thing seems work, don't know why...

$('#my-form :input').each( function() {   alert(this.type); } ); 

the above give text , textarea guess. when use first, gives undefined.

given id of element, how can find type of it.

thank in advance.

input normal tag, should use:

$('#my-form input').each( function() {   alert(this.type); }); 

this return undefined:

$('#title').type 

because $("#title") jquery object , type property of html element. can html element jquery object this:

$('#title').get(0).type 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -