gpt4 book ai didi

javascript - jQuery .is (":disabled") - 为什么这不起作用?

转载 作者:太空宇宙 更新时间:2023-11-03 20:36:45 25 4
gpt4 key购买 nike

http://jsfiddle.net/hw4bz89k/

为什么以下不返回“真”?我知道我一定遗漏了一些基本的东西。

var test = $("#test");
test.prop("disabled", true);
alert(test.is(":disabled"));
#test {
width: 100px;
height: 50px;
background-color: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<div id="test"></div>

最佳答案

你不能disable一个<div>元素。

来自 :disable 的 jQuery 文档

The :disabled selector should only be used for selecting HTML elements that support the disabled attribute (<button>, <input>, <optgroup>, <option>, <select>, and <textarea>).

关于javascript - jQuery .is (":disabled") - 为什么这不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32086156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com