我有这个代码给我一个关于提交按钮的翻转,我试图让它更通用:
$('.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});
}
);
Run Code Online (Sandbox Code Playgroud)
真的有两件事,
我想学习如何操作srcPath变量以将文本'-over'附加到gif文件名,为翻转提供新图像.有谁能建议这样做的方法?
此外,有人可以告诉我这个代码是否可以完善?我对jQuery有点新意,并想知道语法是否可以改进.
非常感谢.
jquery ×1