国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

jQuery common event operations

Common event operations


##dom1 level event setting

    ##<input type=”text” onclick=”Procedural code” value=’tom’ />
  • <input type=”text” onclick=”function()” />
  • ##itnode.onclick = function(){}
  • itnode.onclick = function;

##dom2 level event setting

##itnode.addEventListener(type, processing, event stream);

  • itnode.removeEventListener(type, Processing, event flow);

  • node.attachEvent();

  • node.detachEvent();

##jquery event settings


$ ().Event type (event processing function fn); //Set event

##$().Event type(); //Trigger event execution
  • Event types: click, keyup, keydown, mouseover, mouseout, blur, focus, etc.
  • ##For example: $('div').click(function(){event Trigger process this});

  • Note: This method inside the event function represents the dom node object inside the jquery object.
  • <!DOCTYPE html>
    <html>
        <head>
            <title>php.cn</title>
            <meta charset="utf-8" />
            <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
            <script>
            $(function(){
                //頁面加載完畢給div綁定事件
                $('div').click(function(){
                    console.log('誰在碰我呢');
                });
                //$('li').each(function(){
                    //this關(guān)鍵字分別代表每個li的dom對象
                    //jquery使用時,代碼結(jié)構(gòu)類似這樣的,this都代表dom對象
                //});
                $('div').mouseover(function(){
                    //this.style.backgroundColor = "blue";
                    //$(this)使得this的dom對象變?yōu)閖query對象
                    $(this).css('background-color','red');
                });
            });
            function f1(){
                //間接觸發(fā)對象的事件執(zhí)行
                $('div').click(); //使得div的單擊事件執(zhí)行
                $('div').mouseover();  //鼠標移入事件執(zhí)行
            }
            </script>
            <style type="text/css">
            div {width:300px; height:200px; background-color:pink;}
            </style>
        </head>
        <body>
            <div></div>
            <input type="button" value="間接操作" onclick="f1()" />
        </body>
    </html>
Continuing Learning
||
<!DOCTYPE html> <html> <head> <title>php.cn</title> <meta charset="utf-8" /> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script> $(function(){ //頁面加載完畢給div綁定事件 $('div').click(function(){ console.log('誰在碰我呢'); }); //$('li').each(function(){ //this關(guān)鍵字分別代表每個li的dom對象 //jquery使用時,代碼結(jié)構(gòu)類似這樣的,this都代表dom對象 //}); $('div').mouseover(function(){ //this.style.backgroundColor = "blue"; //$(this)使得this的dom對象變?yōu)閖query對象 $(this).css('background-color','red'); }); }); function f1(){ //間接觸發(fā)對象的事件執(zhí)行 $('div').click(); //使得div的單擊事件執(zhí)行 $('div').mouseover(); //鼠標移入事件執(zhí)行 } </script> <style type="text/css"> div {width:300px; height:200px; background-color:pink;} </style> </head> <body> <div></div> <input type="button" value="間接操作" onclick="f1()" /> </body> </html>
submitReset Code