views:

42

answers:

2

I need a way to determine if a returned object is a textarea (for example).

+7  A: 

Try with:

$('selector').is('textarea');

Or:

alert($('selector')[0].type);
Sarfraz
and with $("textarea.foo"), jquery will return only textarea's with the class "foo". It is no detection like the given answer, but a more precise way of selection
Justus Romijn
@Justus Romijn: Sure it depends on selector specified.
Sarfraz
@Sarfraz your answer is bulls-eye, I just wanted to point out that css-selection (which jQuery uses) is totally awesome :)
Justus Romijn
+2  A: 
$("selector").attr('type')
NimChimpsky
would it work for textarea, which have no type?
yossi