Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在JQUERY中插入背景图像_Jquery_Html_Css - Fatal编程技术网

如何在JQUERY中插入背景图像

如何在JQUERY中插入背景图像,jquery,html,css,Jquery,Html,Css,好的,这就是我的问题,我现在有一个纯白色的列,当用户悬停在该列上时,我希望将其转换为图片(背景图像),这就是我正在做的: $("#column2").hover(function() { $("#column2").css("background-image", "url(/Users/Atticus/Desktop/Screen Shot 2015-09-18 at 7.37.06 PM.png)"); }); 在url周围添加单引号: $("#column2").hover(fun

好的,这就是我的问题,我现在有一个纯白色的列,当用户悬停在该列上时,我希望将其转换为图片(背景图像),这就是我正在做的:

$("#column2").hover(function() {
    $("#column2").css("background-image", "url(/Users/Atticus/Desktop/Screen Shot 2015-09-18 at 7.37.06 PM.png)");
});

在url周围添加单引号:

$("#column2").hover(function() {
    $("#column2").css("background-image", "url('/Users/Atticus/Desktop/Screen Shot 2015-09-18 at 7.37.06 PM.png')");
});

您是否尝试将URL包装到
-引号中的图像。这可能是一个问题,空白在URI中无效。。。检查这里:Ragdata是正确的。我建议将您的文件重命名为更难忘的文件,而不是随机的屏幕截图。为什么您需要在jQuery中执行此操作,您可以在CSS中执行
#column2:hover{background image:url(…)}
方法需要第二个参数,以便在鼠标离开时删除背景图像。非常感谢您,祝您晚安,不用担心。注意上述评论。特别是关于使用CSS的。