【发布时间】:2008-10-24 15:02:51
【问题描述】:
我有这段代码可以让我在提交按钮上滚动,我正在尝试使它更通用:
$('.rollover').hover(
function(){ // Change the input image's source when we "roll on"
srcPath = $(this).attr("src");
srcPathOver = ???????
/*need to manipulate srcPath to change from
img/content/go-button.gif
into
img/content/go-button-over.gif
*/
$(this).attr({ src : srcPathOver});
},
function(){ // Change the input image's source back to the default on "roll off"
$(this).attr({ src : srcPath});
}
);
真的有两件事,
我想了解如何操作srcPath 变量以将文本“-over”附加到 gif 文件名上,从而为翻转提供新图像。谁能建议一种方法来做到这一点?
另外,有人能告诉我这段代码是否可以改进吗?我对 jQuery 有点陌生,想知道是否可以改进语法。
非常感谢。
【问题讨论】:
标签: jquery