I have the following statically programmed button:
<a class="btn dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)" id="action" disabled="disabled">
And want to check if the button is disabled so I can set the preventDefault() because, if it is not set to disabled (by another function) the button must do its work.
<script type="text/javascript">
$(document).ready(function(){
// IF ACTION BUTTON IS DISABLED, DISABLE DROPDOWN CLICK
if ($('#action').is(':disabled')) {
alert("inside if");
event.preventDefault();
return false;
};
});
</script>
But it never throws me the alert. I can see with inspect element the button has disabled="disabled" attribute so it should work. What am I doing wrong?
note: I am using jQuery, so if that is applicable then please point out :)