/**
匿名函数
**/
呵,顾名思义,没有名字,比方匿名信;
你出示的代码中没有名字的函数,用法与下面类似:
/**
k.onclick = function() { multiplerows( this, 'clicked' ); };
k.onmouseover = function() { multiplerows( this, 'hovered' ); };
k.onmouseout = function() {
if( this.className.indexOf( 'hovered' )>-1 ) { multiplerows( this, 'hovered' ); } };
}
}
***/
另一方面,你也可去创建一个函数对象,比方k.onclick = new Function(this,'clicked',"alert(this.innerText)");
匿名函数
**/
呵,顾名思义,没有名字,比方匿名信;
你出示的代码中没有名字的函数,用法与下面类似:
/**
k.onclick = function() { multiplerows( this, 'clicked' ); };
k.onmouseover = function() { multiplerows( this, 'hovered' ); };
k.onmouseout = function() {
if( this.className.indexOf( 'hovered' )>-1 ) { multiplerows( this, 'hovered' ); } };
}
}
***/
另一方面,你也可去创建一个函数对象,比方k.onclick = new Function(this,'clicked',"alert(this.innerText)");
http://4umi.com/web/javascript/tablehilite.htm但是我不知道怎么具体实现它,我现在有一个普通的html,里面有一个table,然后还有一个css文件,就是例子最底下的那几个值,然后我应该怎么做呢,怎么调用这个函数呢? 我觉得这应该整个是一个函数吧,用onload事件吗?好像不是这么用的
(function() {
var t = document.getElementsByTagName( 'table' ), i = t.length, j, k;
while( i-- ) {
j = t[i].rows.length;
while( --j > 1 ) {
k = t[i].rows[j];
k.onclick = function() { multiplerows( this, 'clicked' ); };
k.onmouseover = function() { multiplerows( this, 'hovered' ); };
k.onmouseout = function() {
if( this.className.indexOf( 'hovered' )>-1 ) { multiplerows( this, 'hovered' ); } };
}
}
})();