【发布时间】:2009-04-08 20:59:59
【问题描述】:
除了解释,javascript中的$是什么意思?代码如下:
var ZebraTable = {
bgcolor: '',
classname: '',
stripe: function(el) {
if (!$(el)) return;
var rows = $(el).getElementsByTagName('tr');
for (var i=1,len=rows.length;i<len;i++) {
if (i % 2 == 0) rows[i].className = 'alt';
Event.add(rows[i],'mouseover',function() {
ZebraTable.mouseover(this); });
Event.add(rows[i],'mouseout',function() { ZebraTable.mouseout(this); });
}
},
mouseover: function(row) {
this.bgcolor = row.style.backgroundColor;
this.classname = row.className;
addClassName(row,'over');
},
mouseout: function(row) {
removeClassName(row,'over');
addClassName(row,this.classname);
row.style.backgroundColor = this.bgcolor;
}
}
window.onload = function() {
ZebraTable.stripe('mytable');
}
这是我获取代码的链接,您可以在页面上查看演示。它似乎没有使用任何框架。我实际上正在阅读一个 JQuery 教程,该教程采用此代码并在其上使用 JQuery 来进行表条带化。这是链接:
http://v3.thewatchmakerproject.com/journal/309/stripe-your-tables-the-oo-way
【问题讨论】:
标签: javascript jquery