zoukankan      html  css  js  c++  java
  • 表单元素操作,button,点击下载按钮实现-长知识

    禁用按钮

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
    <button id="btn">Click Me</button>
    <script>
        var obtn = document.getElementById('btn');
    
        obtn.onclick = function () {
    //        this.disabled = true;
    //        this.setAttribute('disabled', 'true');
        }
    
    </script>
    </body>
    </html>

    小技巧:

     location.href 实现点击下载功能

    http://www.cnblogs.com/zichi/p/4929930.html

    45个JavaScript小技巧

    http://www.cnblogs.com/zichi/p/5094902.html

    【优雅代码】深入浅出 妙用Javascript中apply、call、bind
    http://www.cnblogs.com/coco1s/p/4833199.html

    常用的表单事件及用法--select option


    记录一下常用的表单事件,因为工作中常用到所以特别记录一下。有jq写法和原生js写法

    1.这是select的option的事件,jq写法

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <script src="../jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    $(function () {
    
        $('#sel').change(function () {
            
            console.log( $(this).val() );
        })
        
    })
    
    </script>
    </head>
    <body>
        <select name="" id="sel">
            <option value="aaa" selected="selected">111</option>
            <option value="bbb">222</option>
            <option value="ccc">333</option>
        </select>
        <p>
            jQuery中获得选中select值
            var checkText=$("#select_id").find("option:selected").text();  //获取Select选择的Text
            var checkValue=$("#select_id").val();  //获取Select选择的Value
            var checkIndex=$("#select_id ").get(0).selectedIndex;  //获取Select选择的索引值
            var maxIndex=$("#select_id option:last").attr("index");  //获取Select最大的索引值
        </p>
        <p>来源:http://www.cnblogs.com/mitang/p/3687353.html</p>
    </body>
    </html>

    HTML 下拉框 select option 详解
    http://blog.csdn.net/sanyuesan0000/article/details/8593863

  • 相关阅读:
    区块链简单模拟的一些资料
    解析配置文件的一段练习代码
    go语言字符串练习
    20180613更新 leetcode刷题
    啊哈 算法 中 图相关算法
    paxos 练手 推进中
    传智播客8月C/C++基础班开班
    虚拟机最佳实践:单个 VM、临时存储和已上传磁盘
    在微软平台上运行 SAP 应用程序
    了解 Windows Azure 存储的可伸缩性、可用性、持久性和计费
  • 原文地址:https://www.cnblogs.com/masita/p/5039134.html
Copyright © 2011-2022 走看看