jquery更改背景图像 [英] jquery change background-image

查看:110
本文介绍了jquery更改背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用jQuery交换两个图像。使用悬停事件我试过:

  $(#wlt-DealView .buyButton_new)。mouseover(function(e){ 
$('。buyButton_new')。css('background-image','url(../ images / compra_mouseOver.png)');
});
$(#wlt-DealView .buyButton_new)。mouseout(function(e){
$('。buyButton_new')。css('background-image','url /compra_normal.png)');
});

但是图像没有显示,当我得到鼠标后,它触发第二个事件。



您可以在这里查看: http://107.20.186.103/

h2_lin>解决方案

如果我尝试输入网址 http://107.20 。



http://107.20.186.103/deals/images/compra_mouseOver.png 得到一个奇怪的500 ...



我想你应该得到你的图像文件准备好,它会工作。您也可以使用jQuery.hover函数调整您的代码。


I'm trying to swap two images with jQuery. Using the hover event I tried:

$("#wlt-DealView .buyButton_new").mouseover(function(e){
    $('.buyButton_new').css('background-image','url(../images/compra_mouseOver.png)');
});
$("#wlt-DealView .buyButton_new").mouseout(function(e){
    $('.buyButton_new').css('background-image','url(../images/compra_normal.png)');
});

But the image is not showing and after I get the mouse from it, it triggers the second event. It should update with the first image, but it doesn't.

You can have a look here: http://107.20.186.103/deals/cuerpon.

Hover the BUY button.

解决方案

If i try to enter the URL http://107.20.186.103/images/compra_mouseOver.png manually in my browser, i get a 404.

http://107.20.186.103/deals/images/compra_mouseOver.png gets a strange 500...

I think you should get your image files ready and it will work. You may also tweak your code by using the jQuery.hover function.

这篇关于jquery更改背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆