我是靠谱客的博主 清爽香氛,这篇文章主要介绍jquery怎么给元素增加disable属性,现在分享给大家,希望可以做个参考。

本教程操作环境:windows7系统、jquery1.10.2版本、Dell G3电脑。

disabled 属性规定应该禁用 元素。被禁用的元素既不可用,也不可点击。

jquery给元素增加disable属性的方法

attr() 方法可设置被选元素的属性值。

使用attr() 方法给元素增加disable属性有两种方法

复制代码
1
2
$(selector).attr("disabled",true); $(selector).attr("disabled","disabled");
登录后复制

示例:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ // $("input").attr("disabled",true); $("input").attr("disabled","disabled"); }); }); </script> </head> <body> <input type="text" /> <br><br> <button>增加disable属性</button> </body> </html>
登录后复制

1.gif

相关视频教程推荐:jQuery教程(视频)

以上就是jquery怎么给元素增加disable属性的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是清爽香氛最近收集整理的关于jquery怎么给元素增加disable属性的全部内容,更多相关jquery怎么给元素增加disable属性内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(104)

评论列表共有 0 条评论

立即
投稿
返回
顶部