jquery如何让select不可用


当前第2页 返回上一页

主要使用removeAttr方法移除disabled属性来取消禁用

1

$("#select").removeAttr("disabled");

示例:jquery让select不可用

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Title</title>

    <style>

        select{  /*为了看到效果这里添加了宽和高*/

            width:100%;

            height:100px;

            margin:100px 0;

        }

    </style>

    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

</head>

<body>

    <div id="div1">

        <select id="select1">

            <option value="1">我是第一个option</option>

            <option value="2">我是第二个option</option>

            <option value="3">我是第三个option</option>

            <option value="4">我是第四个option</option>

        </select>

    </div>

    <div id="select2">

        <select>

            <option value="1">我是第一个option</option>

            <option value="2">我是第二个option</option>

            <option value="3">我是第三个option</option>

            <option value="4">我是第四个option</option>

        </select>

    </div>

    <script>

        $(function(){

            $("select").each(function () {

                $(this).attr("disabled","disabled");

            });

        });

    </script>

</body>

</html>

更多编程相关知识,请访问:编程教学!!

以上就是jquery如何让select不可用的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

vue.js的ul-li标签仿select标签

jQuery中hasclass()的意思及用法详解

jQuery怎么设置属性和样式

jQuery怎么让select不可选

html中引用jQuery的两种方法

jQuery如何判断对象是否获得焦点

jQuery怎么操作select

jQuery是否获得焦点

html select标签的用法你知道吗?html select标签属性介绍

vs如何安装jQuery

更多相关阅读请进入《jQuery》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...