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