zoukankan      html  css  js  c++  java
  • [ jquery 方法 prop(name|properties|key,value|fn) ] 此方法操作元素本身自带的属性

    获取匹配的元素集中第一个元素的属性(property)值或设置每一个匹配元素的一个或多个属性(操作方式与attr相似):

      随着一些内置属性的DOM元素或window对象,如果试图将删除该属性,浏览器可能会产生错误。jQuery第一次分配undefined值的属性,而忽略了浏览器生成的任何错误

      如果第二个参数是callback,那么需要返回的是属性值,函数传参解释如下:

        1:属性名称

        2:返回属性值的函数,第一个参数为当前元素的索引值,第二个参数为原先的属性值

    实例:

    <!DOCTYPE html>
    <html lang='zh-cn'>
    <head>
    <title>Insert you title</title>
    <meta http-equiv='description' content='this is my page'>
    <meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!-- <script type='text/javascript' src='./js/jquery-3.0.0.js'></script> -->
    <script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
    <style type='text/css'>
        #listDemo{list-style:none;}
        #listDemo li{350px;height:20px;margin:10px 0;background:red;text-align:center;font:400 13px/20px 'Courier New';color:#FFF;}
    </style>
    <script type='text/javascript'>
        $(function(){
            $('#user').prop('autocomplete',function(index,oldAttr){
                alert(oldAttr);
            });
        });
    </script>
    </head>
    <body>
       <input type='text' id='user' autocomplete="on" required="required"/>
    </body>
    </html>
  • 相关阅读:
    xhr
    原生js的博客
    webstorm调试Node的时候配置
    multiparty
    bluebird
    Nodejs+express+angularjs+mongodb
    mustache.js
    ModelProxy 前端接口配置建模框架
    浏览器跨域访问解决方案
    前端性能优化补充篇
  • 原文地址:https://www.cnblogs.com/mysearchblog/p/5605482.html
Copyright © 2011-2022 走看看