JavaScriptはイベントエージェントを通して表の行をハイライト表示する方法です.
2459 ワード
本論文の例は、JavaScriptがイベントエージェントを介して表の行をハイライト表示する方法を説明する.皆さんの参考にしてください.具体的な実現方法は以下の通りです.
Second.のanother
A third.no another
Fourth for luck.no another
&噫13;
var addEvent=function(elem,eventType,func){&菗13;
if(elem.addEvent Listener)&噫13;
addEvent=function(elem,eventType,func){&菗13;
elem.addEventListener(eventType、func、false);
^;&菗13;
else if(elem.atachEvent)&噫13;
addEvent=function(elem,eventType,func){&菗13;
elem.atachEvent('on'+eventType,func);&菗13;
^;&菗13;
addEvent(elem、eventType、func);
}、&菗13;
var delegateEvent=function(elem,childElems,eventType,func,args){啱13;
addEvent(elem,eventType,function(e){&菗13;
var evt=e𞓜window.event;
var elem=evt.target𞓜evt.srclement;&萶13;
if(elem.nodeName.toLowerCase()=child Elems.toLowerCase(){&唵13;
func(elem、args);
}&{13;
③;&嚓13;
}、&菗13;
Function highlightRows(obj,args){&菗13;
if(&args;&args.over){&菗13;
obj.prevColour=obj.parent Node.style.background Color;
obj.parent Node.style.background Color=args.co lour;
if(args.index&&obj.title==「」)&啱13
obj.title="Row"+obj.parent Node.rowIndex;&菗13;
}else{&嚓13;
obj.parent Node.style.background Color=";
if(obj.title.indexOf(「Row」)+1)&菗13;
obj.title=“”&唵13;
}&{13;
}&{13;
function init(){&{13;
delegateEvent(document.getElementById('thetable')、'td'、'mouseover'、&啢唵13;
highlight Rows,''colour':'light blue','over':true,&唳13;
'index':true';&唵13;
delegateEvent(document.getElementById('thetable')、'td'、'mouseout'、&啢唵13;
highlight Rows、{over':false}、&菗13;
}&{13;
addEvent(window,'load',init)&13;
本論文で述べたように、皆さんのjavascriptプログラムの設計に役に立ちます.
Highlight Rows
Just one.no anotherSecond.のanother
A third.no another
Fourth for luck.no another
&噫13;
var addEvent=function(elem,eventType,func){&菗13;
if(elem.addEvent Listener)&噫13;
addEvent=function(elem,eventType,func){&菗13;
elem.addEventListener(eventType、func、false);
^;&菗13;
else if(elem.atachEvent)&噫13;
addEvent=function(elem,eventType,func){&菗13;
elem.atachEvent('on'+eventType,func);&菗13;
^;&菗13;
addEvent(elem、eventType、func);
}、&菗13;
var delegateEvent=function(elem,childElems,eventType,func,args){啱13;
addEvent(elem,eventType,function(e){&菗13;
var evt=e𞓜window.event;
var elem=evt.target𞓜evt.srclement;&萶13;
if(elem.nodeName.toLowerCase()=child Elems.toLowerCase(){&唵13;
func(elem、args);
}&{13;
③;&嚓13;
}、&菗13;
Function highlightRows(obj,args){&菗13;
if(&args;&args.over){&菗13;
obj.prevColour=obj.parent Node.style.background Color;
obj.parent Node.style.background Color=args.co lour;
if(args.index&&obj.title==「」)&啱13
obj.title="Row"+obj.parent Node.rowIndex;&菗13;
}else{&嚓13;
obj.parent Node.style.background Color=";
if(obj.title.indexOf(「Row」)+1)&菗13;
obj.title=“”&唵13;
}&{13;
}&{13;
function init(){&{13;
delegateEvent(document.getElementById('thetable')、'td'、'mouseover'、&啢唵13;
highlight Rows,''colour':'light blue','over':true,&唳13;
'index':true';&唵13;
delegateEvent(document.getElementById('thetable')、'td'、'mouseout'、&啢唵13;
highlight Rows、{over':false}、&菗13;
}&{13;
addEvent(window,'load',init)&13;
本論文で述べたように、皆さんのjavascriptプログラムの設計に役に立ちます.