!!!常用jquery代碼

來源:互聯網
上載者:User

標籤:style   class   blog   code   java   http   

文檔:

<!doctype html><html><head><meta charset="utf-8"><title></title><!-- <link href="css.css" type="text/css" rel="stylesheet" /> --><!-- <script src="http://www.expai.com/js/jquery-1.8.3.min.js"></script> --><!-- <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> --><!-- <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> --><!-- <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> --><script src="http://code.jquery.com/jquery-1.11.1.min.js"></script><script type="text/javascript">$(function(){    $("#div1").click(function(){    });});</script><style type="text/css"></style></head><body></body></html>

 

事件:

$(window).resize(function() {});$(".div1").live("mouseenter",function(event){});$(".div1").live("mouseleave",function(event){});$(".div1").bind("click",function(){});$(document).live("click",function(event){    event.stopPropagation();});

 

AJAX:

var requestUrl="http://localhost/1.html?callback=?";$.ajax({    type : "get",    async:true,    url : requestUrl,    data : "channelid=7&current=1&rowSize=4",    dataType : "jsonp",    success :function(data){        console.log("--------(xxxxx)-----success");    },    error:function(data){        console.log("error: (xxxxx)");    }});

 

 

遍曆:

$("li").each(function(){    alert($(this).html())});
var ee=$("li");var len=ee.length;for(var i=0;i<len;i++)    if(    $("li").eq(i).is(":visible")==true  ){        alert("顯示");    }else{        alert("none");    }}

 

動畫、顯示隱藏:

$(".dot0").stop(true,true).show();

 

延時:

setTimeout(function(){},3000);

 

 

 

 

 

 

 

檢測瀏覽器:

EpBrowser = {    version: 0,    core: "",    userAgent: "",//userAgent    init:function() {        var ua = navigator.userAgent.toLowerCase();        var s;        var name =‘‘;        var ver = 0;        this.userAgent=ua;        (s = ua.match(/msie ([\d.]+)/)) ? this._set("ie", this._setVersion(s[1])):        (s = ua.match(/firefox\/([\d.]+)/)) ? this._set("firefox", this._setVersion(s[1])) :        (s = ua.match(/chrome\/([\d.]+)/)) ? this._set("chrome", this._setVersion(s[1])) :        (s = ua.match(/opera.([\d.]+)/)) ? this._set("opera", this._setVersion(s[1])) :        (s = ua.match(/version\/([\d.]+).*safari/)) ? this._set("safari", this._setVersion(s[1])) : 0;    },    _setVersion:function(ver,floatLength) {        ver = (‘‘ + ver).replace(/_/g, ‘.‘);        ver = String(ver).split(‘.‘);        return parseInt(ver[0]);    },    _set:function(bname,bver) {        this.core=bname;        this.version=bver;    }
  log:function(msg) {
if(  (EpBrowser.core=="chrome")  ){//chromeconsole.log("log>>    "+msg);}  }
};

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.