Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.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
Javascript 每位家长';s div应该有自己的背景。图像的路径在内部。怎么做?_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 每位家长';s div应该有自己的背景。图像的路径在内部。怎么做?

Javascript 每位家长';s div应该有自己的背景。图像的路径在内部。怎么做?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,如何使每个块背景与图片上的路径相同。 我不明白。现在所有的方块都是背景 var-width=document.documentElement.clientWidth, 高度=宽度/3, bg=$('.views字段nothing').find('.views').html(); bg=“url(“+bg+”)”; //$(“.views字段无”).attr(” .views字段无任何内容{ 边框:1px纯红; } http://goodimg.ru/img/tsvetochek-risuno

如何使每个块背景与图片上的路径相同。 我不明白。现在所有的方块都是背景

var-width=document.documentElement.clientWidth,
高度=宽度/3,
bg=$('.views字段nothing').find('.views').html();
bg=“url(“+bg+”)”;
//$(“.views字段无”).attr(”
.views字段无任何内容{
边框:1px纯红;
}

http://goodimg.ru/img/tsvetochek-risunok3.jpg
http://agu-shop.ru/images/pink_flower_512x512.png
http://www.raskraska.ru/counting/flower-bw.gif

js
在问题中显示为只设置第一个
背景
。不查看任何字段
元素

使用
.each()
迭代所有
.views字段nothing
bg
元素,通过使用选择器
$(“.views”,this)
.html()
在循环中设置
宽度
高度
背景

var-width=document.documentElement.clientWidth,
高度=宽度/3,
bg=$(“.views字段无”);
bg.each(函数(){
$(this.css)({
背景:“url(“+$(“.views”,this.html()+”),
高度:高度,,
宽度:宽度
})
});
.views字段无任何内容{
边框:1px纯红;
}

http://goodimg.ru/img/tsvetochek-risunok3.jpg
http://agu-shop.ru/images/pink_flower_512x512.png
http://www.raskraska.ru/counting/flower-bw.gif

js
在问题中显示为只设置第一个
背景
。不查看任何字段
元素

使用
.each()
迭代所有
.views字段nothing
bg
元素,通过使用选择器
$(“.views”,this)
.html()
在循环中设置
宽度
高度
背景

var-width=document.documentElement.clientWidth,
高度=宽度/3,
bg=$(“.views字段无”);
bg.each(函数(){
$(this.css)({
背景:“url(“+$(“.views”,this.html()+”),
高度:高度,,
宽度:宽度
})
});
.views字段无任何内容{
边框:1px纯红;
}

http://goodimg.ru/img/tsvetochek-risunok3.jpg
http://agu-shop.ru/images/pink_flower_512x512.png
http://www.raskraska.ru/counting/flower-bw.gif