How To Check If Div Element Is Disabled Using Jquery
Solution 1:
ASP.NET allows you to set Disabled
attribute on any HtmlControl object. And in your example it renders as
<div id="divUndo" disabled="disabled"><div>
and in javascript can be checked like
$('#divUndo').attr('disabled') !== undefined
But according to W3C
The following elements support the disabled attribute: BUTTON, INPUT, OPTGROUP, OPTION, SELECT, and TEXTAREA.
Therefore it may not work or work differently in different browsers. You shouldn't rely on using disabled
attribute on div
in your javascript or css.
Solution 2:
In standard ASP.Net Webforms, when you set the disabled property to true it renders like:
<div id="MainContent_divundo" disabled="disabled">This is Undo!</div>
You can probably use the the standard jQuery attr() method to read the value. Most likely prop() will not work (jsFiddle).
if ($("#MainContent_divundo").attr("disabled") == "disabled")
{
}
I don't know why you'd want to do this, so this is most likely a XY Problem.
Solution 3:
You can't disable a div in any way that JavaScript (or HTML, for that matter) would recognize. It may be a weird .net attribute of some sort, but not something the client side would recognize.
If you can explain what your ultimate goal is, we could perhaps assist you with some alternatives.
Post a Comment for "How To Check If Div Element Is Disabled Using Jquery"