【发布时间】:2009-07-07 22:28:28
【问题描述】:
我正在使用以下代码将悬停效果应用于名为工具栏的 div 中的一组图像:
$("#toolbar img").hover(
function()
{
this.src = this.src.replace("_off", "_on");
},
function()
{
this.src = this.src.replace("_on", "_off");
}
);
但我也想将相同的效果应用于名为 tabs 的 div 而不重复相同的代码。我不能按照这些思路做点什么:
$("#toolbar, #tabs img").hover(
function()
{
this.src = this.src.replace("_off", "_on");
},
function()
{
this.src = this.src.replace("_on", "_off");
}
);
问题是上述仅适用于“选项卡” div,而工具栏停止工作。我想我只是弄错了 jQuery 语法,对 jQuery 来说还是个新手
【问题讨论】:
标签: javascript jquery