织梦标签的调用,图片在js里,应该怎么调用,求高手解答??
我在做一个网站,是一张顶部的图片来着,可这张图片是在JS里面,应该怎么用标签去调用啊?下面是JS的代码:<script>$(function(){var$hero=$('...
我在做一个网站,是一张顶部的图片来着,可这张图片是在JS里面,应该怎么用标签去调用啊?下面是JS的代码:
<script>$(function () {
var $hero=$('.hero');
var $indicator = $('.loading-indicator');
var $heroBg = $('.hero-bg');
$hero.css('opacity',0);
var img=new Image();
img.src="/blog/header/blogpic0529.png";
img.onload=function(){
var cover=document.getElementsByClassName('hero')[0];
cover.style.backgroundImage='url(/templets/default/images/blogpic0529.png)';
$indicator.animate({opacity: 0}, 500, function(){
$heroBg.animate({opacity:0},700);
$hero.animate({opacity:1},700);
});
}
window.onscroll = function(){
var offsetY=$(window).scrollTop();
var opacityValue = 1.*(500-offsetY)/500;
$hero.css('opacity', opacityValue);
}
})</script>
<body>
<div class="hero-bg"><div class="loading-indicator"><span class="loader-dot"></span><span class="loader-dot"></span><span class="loader-dot"></span></div></div><div class="hero"></div>
</body>
因为我对js代码也不太懂,就发有关的代码上来供参考一下
我想调用文章里面的缩略图... 展开
<script>$(function () {
var $hero=$('.hero');
var $indicator = $('.loading-indicator');
var $heroBg = $('.hero-bg');
$hero.css('opacity',0);
var img=new Image();
img.src="/blog/header/blogpic0529.png";
img.onload=function(){
var cover=document.getElementsByClassName('hero')[0];
cover.style.backgroundImage='url(/templets/default/images/blogpic0529.png)';
$indicator.animate({opacity: 0}, 500, function(){
$heroBg.animate({opacity:0},700);
$hero.animate({opacity:1},700);
});
}
window.onscroll = function(){
var offsetY=$(window).scrollTop();
var opacityValue = 1.*(500-offsetY)/500;
$hero.css('opacity', opacityValue);
}
})</script>
<body>
<div class="hero-bg"><div class="loading-indicator"><span class="loader-dot"></span><span class="loader-dot"></span><span class="loader-dot"></span></div></div><div class="hero"></div>
</body>
因为我对js代码也不太懂,就发有关的代码上来供参考一下
我想调用文章里面的缩略图... 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询