jquery hover在chrome和IE中不起作用,但在FF中有效

时间:2013-07-06 19:31:09

标签: jquery

这是我用于将鼠标悬停在导航菜单项上的代码: 有人可以帮我解决Chrome和IE中的问题

$("#unlock_nav a").hover(function () {
 $(this).css('background-image', 'url(http://www.eileenfisher.com/ns/images/13f_m2/sbi_features/unlocked_season/but_' + $(this).attr('href').slice(1) +'_pink.png');

 },

function(){
 $(this).css('background-image', 'url(http://www.eileenfisher.com/ns/images/13f_m2/sbi_features/unlocked_season/but_' +  $(this).attr('href').slice(1) + '_white.png');
   }); 

1 个答案:

答案 0 :(得分:1)

您忘记将近距离括号放在背景图片网址中。

试试这个:

$("#unlock_nav a").hover(function () {
 $(this).css('background-image', 'url(http://www.eileenfisher.com/ns/images/13f_m2/sbi_features/unlocked_season/but_' + $(this).attr('href').slice(1) +'_pink.png)');

 },

function(){
 $(this).css('background-image', 'url(http://www.eileenfisher.com/ns/images/13f_m2/sbi_features/unlocked_season/but_' +  $(this).attr('href').slice(1) + '_white.png)');
   });

示例:http://jsfiddle.net/9nQdm/3/

相关问题