tags:

views:

35

answers:

1

Hi All,

Jquery newbie here.

In a wrapped element set, is there a way to check if the element supports this property?

I basically have this pseudocode.

$(function () {
    $("form").each(function(){
        if("this element supports disabled"){
            $(this).attr("disabled", "disabled");
        }
    });
});

I was thinking that if the element does not support this property then it should be skipped.

In my example above, I was checking if the element supports the disabled attribute.

Thanks

+3  A: 

It really isn't possible to tell because you can set an attribute on an element even if it doesn't support it. As far as I know, only form elements support the disabled property, so you can just check if the element is of type input, select, textarea or button. (there may be a few more that I missed)

casablanca
Other elements are `option` and `optgroup` - http://www.w3.org/TR/html401/interact/forms.html#h-17.12.1
Chetan Sastry
what about the multiple="multiple" property? Only select tag can support this..
Mark Estrada