zoukankan      html  css  js  c++  java
  • jQuery——属相操作

    属性获取:attr(属性名),

    属性设置:attr(属性名,具体值)

    移除属性:removeAttr(属性名)

    特殊情况:prop(属性名)、prop(属性名,具体值);表单中状态属性checked、selected、disabled要使用.prop()方法

    使用技巧:整体移除class属性,可以用removeAttr("class")

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="jquery-1.11.1.js"></script>
        <script>
            $(function () {
                $("button").eq(0).on("click", function () {
                    $("input").prop("checked", true);
    
                });
                $("button").eq(1).on("click", function () {
                    $("input").removeAttr("checked");
                });
            });
    
        </script>
    </head>
    <body>
    <button>设置</button>
    <button>移除</button>
    <input type="radio"><div></div>
    </body>
    </html>
  • 相关阅读:
    作业16
    递归函数
    三元表达式与生成式
    迭代器与生成器
    作业15
    装饰器
    作业14
    string的入门与进阶
    修理牧场(优先队列)
    旅游规划
  • 原文地址:https://www.cnblogs.com/wuqiuxue/p/8038508.html
Copyright © 2011-2022 走看看