如何使用jQuery检查DIV元素是否被禁用 [英] How to check if DIV element is disabled using jquery

查看:202
本文介绍了如何使用jQuery检查DIV元素是否被禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

htmlcode:

div id="divUndo" runat="server"

在某些情况下,我使用以下语句在后面的代码中禁用divUndo. VB.NET:

I am disabling divUndo in the code-behind under certain conditions using the below statement. VB.NET:

divUndo.disabled=true

我如何检查是否禁用了divUndo?

How can I check if the "divUndo" is disabled or not using jquery?

推荐答案

ASP.NET允许您在任何HtmlControl对象上设置Disabled属性.在您的示例中,它呈现为

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>

和javascript中的代码都可以像

and in javascript can be checked like

$('#divUndo').attr('disabled') !== undefined

但是根据W3C

以下元素支持禁用的属性:BUTTON,INPUT, OPTGROUP,OPTION,SELECT和TEXTAREA.

The following elements support the disabled attribute: BUTTON, INPUT, OPTGROUP, OPTION, SELECT, and TEXTAREA.

因此,它可能无法在不同的浏览器中工作或有所不同.您不应该依赖在JavaScript或CSS中使用div上的disabled属性.

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.

这篇关于如何使用jQuery检查DIV元素是否被禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆