zoukankan      html  css  js  c++  java
  • jQuery prop() 方法

    1.方法简介

    prop() 方法设置或返回被选元素的属性和值。

    2.方法示例

    <!DOCTYPE html>
    <html>
        <head>
            <title></title>
        </head>
    
        <body>
          <input type="checkbox" id="ck" />全选
            <br /><br />
            <input type="checkbox" class="ck" />
            <input type="checkbox" class="ck" />
            <input type="checkbox" class="ck" />
            <input type="checkbox" class="ck" />
            <input type="checkbox" class="ck" />
        </body>
    </html>
        <script type="text/javascript" src="js/jquery.min.js" >    </script>
    <script>
    //添加事件的方法:
    $("#ck").click(function(){
    
        //找到自身的选种状态
        //$(this)筛选本身,自身
        $(".ck").prop("checked",$(this).prop("checked"));
        //找到所有的$(".ck"),设置属性:.prop("checked",属性既是上面的自身状态)!
    })
    //找到ck;.click代表点击事件,没有方法的方法名=匿名函数
    
    
    </script>
  • 相关阅读:
    SDN第二次上机作业
    SDN第二次作业
    SDN第一次上机作业
    个人作业-软件产品案例分析
    pandas之Series
    pandas简答介绍
    python爬取英文名
    python爬取动态网页
    python画树
    Python存储数据的方式
  • 原文地址:https://www.cnblogs.com/mr-wuxiansheng/p/6534461.html
Copyright © 2011-2022 走看看