亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

jQueryのコモンイベント操作

通常イベント運(yùn)営


dom1レベルイベント設(shè)定

  • <input type=”text” onclick=”手続きコード” value=’tom’ / t;

  • <input type="text" onclick="function()" />

  • itnode.onclick = function(){}

  • itnode.onclick = function;


domレベル2イベント設(shè)定

  • itnode.addEventListener(タイプ、処理、イベントフロー);

  • itnode.removeEventListener(タイプ、処理、イベントフロー);

  • node.attachEvent();

  • node.detachEvent();


jqueryイベント設(shè)定

  • $().イベントタイプ(イベント処理関數(shù)f) n) / /イベントを設(shè)定します

  • $().Event type(); //イベントの実行をトリガーします

  • イベントタイプ: クリック、キーアップ、キーダウン、マウスオーバー、マウスアウト、ブラー、フォーカスなど

  • 例: $('div').click(function(){イベントトリガープロセス this});

注: イベント関數(shù)內(nèi)のこのメソッドは、jquery オブジェクト內(nèi)の dom ノード オブジェクトを表します。 りー

學(xué)び続ける
||
<!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(){ //頁(yè)面加載完畢給div綁定事件 $('div').click(function(){ console.log('誰(shuí)在碰我呢'); }); //$('li').each(function(){ //this關(guān)鍵字分別代表每個(gè)li的dom對(duì)象 //jquery使用時(shí),代碼結(jié)構(gòu)類似這樣的,this都代表dom對(duì)象 //}); $('div').mouseover(function(){ //this.style.backgroundColor = "blue"; //$(this)使得this的dom對(duì)象變?yōu)閖query對(duì)象 $(this).css('background-color','red'); }); }); function f1(){ //間接觸發(fā)對(duì)象的事件執(zhí)行 $('div').click(); //使得div的單擊事件執(zhí)行 $('div').mouseover(); //鼠標(biāo)移入事件執(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>
提出するリセットコード