coder coder -4 years ago 73
jQuery Question

How is jquery used to check for the 'disabled' attribute on an <a> tag?

I have a

disabled='disabled'
attribute on an
<a>
tag. How do I test to see if this attribute is on my tag using jquery? The following code returns
undefined
. I can see the
disabled
attribute on the tag in firebug and all other attributes on the anchor return successfully using the same syntax. I realize
disabled
is a custom attribute for an
<a>
tag.

$('#anchorID').attr('disabled');

Answer Source

Try

$('#anchorID').is('[disabled=disabled]')

Will return true if disabled="disabled" is an attribute for the element.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download