zoukankan      html  css  js  c++  java
  • i++,++i,Math.max,hasOwnPrototype.ajax,indexOf(),firefox的一些东西,jquery的contains函数,window.open

    一、i++与++i的区别

    1 var i=0;3 console.log(i++)5 0
    1 var j=0;
    2 3 console.log(++j)
    4 1

    a=++i;相当于i=i+1;a=i;

    a=i++;相当于a=i;i=i+1;

    二、Math.max

    1 var arr=[1,3,4,45,5,6,6,7]
    2 undefined
    3 Math.max(arr[0],arr[1],arr[2],arr[3],arr[4],arr[5],arr[6],arr[7])
    4 45
    5 Math.max.call(Math,arr[0],arr[1],arr[2],arr[3],arr[4],arr[5],arr[6],arr[7])
    6 45
    7 Math.max.apply(Math,arr)
    8 45

    三、hasOwnPrototype与isPrototypeOf

    hasOwnProperty: 是用来判断一个对象是否有你给出名称的属性或对象。不过需要注意的是,此方法无法检查该对象的原型链中是否具有该属性,该属性必须是对象本身的一个成员。

    isPrototypeOf : 是用来判断要检查其原型链的对象是否存在于指定对象实例中,是则返回true,否则返回false。

    四、ajax

    ajax() 方法通过 HTTP 请求加载远程数据。$.ajax(opts);opts为json格式,常见参数url、type、data等。
     
    load() 方法从服务器加载数据,并把返回的数据放入被选元素中。$(selector).load(URL,data,callback);
    必需的 URL 参数规定您希望加载的 URL。
    可选的 data 参数规定与请求一同发送的查询字符串键/值对集合。
    可选的 callback 参数是 load() 方法完成后所执行的函数名称。
     
    $.get() 方法通过 HTTP GET 请求从服务器上请求数据。
    $.get(URL,callback);
    必需的 URL 参数规定您希望请求的 URL。
    可选的 callback 参数是请求成功后所执行的函数名。
     
    getScript() 方法通过 HTTP GET 请求载入并执行 JavaScript 文件。
    jQuery.getScript(url,success(response,status));
     
     
    五、
    javascirpt中的数字在计算机内存储为8Byte
     
    六、
    Readonly只针对input(text/password)和textarea有效,而disabled对于所有的表单元素有效,包括select,radio,checkbox,button等。
     
    七、indexOf()
    1 var str='asaa';
    2 undefined
    3 str.indexOf('aa')
    4 2

    大范围的string在前面,需要搜索的字符串在后面,就是大在前,小在后,然后返回的匹配的索引值

    八、firefox
     1.如果父级的高度固定了的话,firefix的div的内嵌div不可以把父级的高度撑大;
      如果父级的高度没有设置的话,firefix的div的内嵌div可以把父级的高度撑大;
     1 <html>
     2 <head>
     3     <meta charset='UTF-8'>
     4     <title>sd</title>
     5     <style>
     6     html,body{
     7         margin:0;
     8         padding:0;
     9     }
    10     #div1{
    11         float: left;
    12         background-color: red;
    13         width:40%;
    14         height:200px;
    15 
    16     }
    17     #div2{
    18         background-color: green;
    19         width:200px;
    20         height:214px;
    21         background-image: url('BC0C62C1B1962A8A.jpg');
    22     }
    23 
    24     </style>
    25 </head>
    26 <body>
    27 <div id='div1'>
    28     <div id='div2'>
    29     </div>
    30 </div>
    31 </body>
    32 </html>

     1 #div1{
     2         float: left;
     3         background-color: red;
     4         40%;
     5         /*height:200px;*/
     6 
     7     }
     8     #div2{
     9         background-color: green;
    10         200px;
    11         height:214px;
    12         background-image: url('BC0C62C1B1962A8A.jpg');
    13     }

    2.当设置为三列布局的时候,firefix的float宽度也是100%;

     九、jquery contains()

    • jQuery( ":contains(text)" )

      text: A string of text to look for. It's case sensitive.

     
    1 <div>John Resig</div>
    2 <div>George Martin</div>
    3 <div>Malcom John Sinclair</div>
    4 <div>J. Ohn</div>
    5 $( "div:contains('John')" ).css( "text-decoration", "underline" )

    十、window.open()

    var windowObjectReference = window.open(strUrl, strWindowName, [strWindowFeatures]);

    strUrl
    The URL to be loaded in the newly opened window. strUrl can be HTML, an image file, or any other resource supported by the browser.
    strWindowName
    A name for the new window. The name can be used as the target of links and forms using the target attribute of <a> or <form> elements. The name should not contain whitespace. Note that strWindowName does not specify the title of the new window.
    strWindowFeatures
    An optional parameter listing the features (size, position, scrollbars, etc.) of the new window as a string. The string must not contain any whitespace, and each feature name and value must be separated by a comma. See Position and size features below for details.
  • 相关阅读:
    UVA
    UVA
    模板——扩展欧几里得算法(求ax+by=gcd的解)
    UVA
    模板——2.2 素数筛选和合数分解
    模板——素数筛选
    Educational Codeforces Round 46 (Rated for Div. 2)
    Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses
    Educational Codeforces Round 46 (Rated for Div. 2) D. Yet Another Problem On a Subsequence
    Educational Codeforces Round 46 (Rated for Div. 2) C. Covered Points Count
  • 原文地址:https://www.cnblogs.com/lwwen/p/5820691.html
Copyright © 2011-2022 走看看