zoukankan      html  css  js  c++  java
  • jq 笔记大全一

    1、页面重新加载
    window.location.reload()
    2、创建一个div标签,
     $("<div>")
    3、 DOM对像直接转为jq  方法用; 比如value 是一个dom 对像, 转为jq方法是
      $(value)
    4、 如果判断一个dom 对像??
     例:如果一个div 页面提示:htmldivElement
    5、一个元素的偏移的方法:
     offset() 里面有两个方法 left() 和top()
    6、height() 、widht() 等一些方法: 
    后面小括号时面为空。则是获取当元素的值, 小括号时面有值 的放在,则是给当前元素添加值 。
    7、给一个数组添加数据
    hArr[index]=h;  // 把高度放到 数组中内
    8、$(window).height()和$("body").height()获取值区别
    window是视图窗口。
    body可以小于窗口,也可以大于窗口(有滚动条时),看你样式定义跟内容了。如果定义了body的width跟height样式,那取到的就是这个值,如果没定义,一般width就跟window的一样,而height则根据内容扩展或收缩。
    9、对浏览器窗口调整
    $(window).resize(function () {
    
            v_h = $(".m-page").height();
    
        });
    10、document.compatMode == "BackCompat"
    盒模型的渲染BackCompat 当document.compatMode等于BackCompat时,浏览器客户区宽度是document.body.clientWidth;
    11、获取隐藏的DIV 的高度
    听说把DIV设置成visibility:hidden;   
    visible 可见,   hidden  不可见
    12、多个ID 绑定同一个事件
    $("#div1", "#divN").click(function() { });
    13、获取当前索引值
        current=$(this).index();
    
    $(".index").find("span").click(function(){
    
                  current=$(this).index();
    
                 slide(current)
    
              });
    14、字符串转JSON。
         str = $.parseJSON(str);
    
       2) 、 var str=JSON.parse()  把字符串转为对像
    15、this 与 $(this)区别
    例: 如查想找到 当前A 的href 
    <div class="nav">
    
    <ul>
    
        <li><a href="1.html"> 首页</a></li>
    
        <li><a href="2.html"> 个人资料</a></li>
    
        <li><a href="3.html"> 我的好友</a></li>
    
        <li><a href="4.html"> 消息管理</a></li>
    
    </ul>  
    
    </div>
    
    <script type="text/javascript">
    
      $(".nav ul li a").each(function(){
    
              var $this=$(this);
    
     
    
           alert($(this[0].href))   // 这样的绝对路径
    
    $this.attr("href")     //这样是 1.html
    
     
    
    })
    
    </script>
    16,求数组中的最小的数。
    
    
    Math.min.apply(null,arry)
    
    
    17、找出一个数在当前数组中的索引值
    
    
    $.isArray(minH,hArry);
    
    
    18:onscroll 方法
     
    19、iframe 与主页面在同一个域。 
    iframe 中的一个ID 中的文字。
    必须用 contents   iframe的父级。
    $('.uEditorIframe').contents().find('#iframeBody').html(),
    20、上传图片  插件 
     
    21.on方法
    <p><a href='#' id='logout'>【退出】</a></p>
    
    p就是父节点。
    
    $('p').on('click', '#count', function() { 
             //function code here. 
     });
    22;beforeSend 
    beforeSend方法用于在向服务器发送请求前添加一些处理函数
    beforeSubmit
    
    
    23  包含类名 和ID 名的
      hasClass()   是类名
      has()
    24  不包含 ID 名和CLASS名的
      not()  用法:
    $("ul li").not("#oDiv").html("24");
    
    $("ul li").not(".oDiv").html("24")
    
    
    25  parseInt() 转为数值型
    
    
    parseInt()
    
    
    
     26、 取消滑屏事件
    $("body").on("touchmove",function(e){
                event.preventDefault();
    });
    
    

    27、下拉刷新

    window.onscroll=function(){
            if(document.documentElement.clientHeight+document.body.scrollTop>=document.body.scrollHeight){
                //执行加载内容。
            }
        }
    28、图片加载完成多张
    var imgLoader={
        imgList:["images/play_girl_normal.png","images/play_lollipop.png","images/play_gold.png","images/play_score.png","images/packet_dialog_close.png","images/packet_dialog.png"],
        loadImgNumber:0,
        load:function(){
            var _this=this;       
            for (var i = 0; i < _this.imgList.length; i++) {
                var imageObj = new Image();
                imageObj.src = "http://"+location.host+meishijia.basePath+"/content/jinbi/"+_this.imgList[i];            
                console.log(imageObj.src);
                imageObj.onload=function(){
                   _this.loadImgNumber++;
                    if(_this.loadImgNumber==_this.imgList.length){
                        $(".load").hide();
                       // game.start();
                    }
                }
    
            }
        },
    }
    
    
    
    29、 JSON 有<br>这样的HTML 的 代码时, 可以用,HTML 来实现换行代码
    例如;
    var wenanJson = [{wenan:'你甜而不腻的外表,让人想起了GD棉花糖,<br>正式聘用你为:日韩区代言人。<br>有效期:<br>此刻——牙掉光',kouling:"哈哈哈"},
                     ];   
                     
    $(".oDiv").html(wenanJson[1].wenan);//左侧文案html 就可以实现换行
    
    
    
    30、 哈希值
    function getHashCode (str,caseSensitive){
        if(!caseSensitive){
            str = str.toLowerCase();
        }
        var hash  =   1315423911,i,ch;
        for (i = str.length - 1; i >= 0; i--) {
            ch = str.charCodeAt(i);
            hash ^= ((hash << 5) + ch + (hash >> 2));
        }
        return  (hash & 0x7FFFFFFF);
    }
    
    

     31、 关于时间倒计时的一个处理

    
    
    var timer = {}    
    // 转换毫秒 js 剩余时间转换
    timer.convertMSjs = function(ms) { if (ms < 1000) return 0; var hours = parseInt(ms / 1000 / 60 / 60 % 24); var minites = parseInt(ms / 1000 / 60 % 60); var seconds = parseInt(ms / 1000 % 60); minites = minites < 10 ? "0" + minites : minites; seconds = seconds < 10 ? "0" + seconds : seconds; if (hours > 0){ return "距结束" + hours+"时"+ minites + "分" + seconds + "秒" }else{ return "距结束" + minites + "分" + seconds + "秒" } } ;

    // 转换毫秒JQ 有24时。
    timer.convertMS = function(ms) {
            if (ms < 1000)
                return 0;
            var dt1 = new Date(Number(ms));
            var day =    dt1.getDate();
            var hours = dt1.getHours();
            var minites = dt1.getMinutes();
            var seconds = dt1.getSeconds();
            
            minites = minites < 10 ? "0" + minites : minites;
            seconds = seconds < 10 ? "0" + seconds : seconds;
            
            if (hours > 0){
                return "距结束" + hours+"时"+ minites + "分" + seconds + "秒"
            }else{
                return "距结束" + minites + "分" + seconds + "秒"
            }
            if(minites==0 && seconds ==0 ){
                if(hours==10 || hours == 15 || hours == 20){
                    return 1;
                    
                }
                
            }
            
    }    ;

    var data = 1465979908000
    var atimer = setInterval(
                    function() {                                    
                    // 简单的时间倒计时     用的js                                        
                     $(".status2").each(function() {
                            var ms = parseInt(data);
                            var showtimes = timer.convertMSjs(ms);
                            if (showtimes == 0) {
                                location.reload();
                                
                            } else {
                                 
                                console.log(showtimes);
                                data -=1000;
                            }
                        });


    }, 1000);
    
    
    


    
    
     
  • 相关阅读:
    rs485
    RS-232
    Delphi CRC算法, 不错
    Delphi Modbus RTU CRC16校验码
    如何使用Delphi编写Modbus RTU CRC16的校验码
    Delphi CRC算法crcexecute
    Delphi CRC32Verify控件
    Delphi CRC16校验算法实现(转)
    delphi crc校验函数
    JavaScript如何一次性展示几万条数据
  • 原文地址:https://www.cnblogs.com/yjhua/p/4595283.html
Copyright © 2011-2022 走看看