仅在javascript中的图像旋转器-没有jquery
Image rotater in javascript only - no jquery
UPDATE:下面的答案似乎有效,但如果我在描述变量的文本中有链接,它似乎根本不会取代文本。如果我删除标签,或任何html标签从所有的文本,我试图取代,它的工作。问题是,我需要的文本被替换为html格式:(
我试图让一个图像褪色,与文本外的图像褪色,并有另一组出现在同一地方。
jquery由于环境原因无法使用
我想到了这个,唯一的问题是,发生的第一件事是第一个图像在一开始就消失,同样的图像出现。然后,在第一个"故障"之后,它开始正常工作。之后,它似乎工作得很好。
谁能指出我愚蠢的错误?<script type="text/javascript">
var links = ["http://www.firstlink.com","http://www.secondlink.com","http://www.thirdlink.com"];
var images = ["1stimage.jpg","2ndimage.jpg","3rdimage.jpg"];
var descriptions=["this is the first set of rotating text", "Now we have another set of text, in this large paragraph. Write whatever we want here", "and this is the last set of text, we have 3 images. We can add more images and more text."]
var i = 0;
var renew = setInterval(function(){
if(links.length == i){
i = 0;
}
else {
document.getElementById("bannerImage").src = images[i];
fadeIn(document.getElementById("bannerImage"), 1000);
document.getElementById("bannerLink").href = links[i];
document.getElementById("p1").innerHTML= descriptions[i];
i++;
}
},5000);
</script><script type="text/javascript">
function fadeIn(el, time) {
el.style.opacity = 0;
el.style.display = "block";
var last = +new Date();
var tick = function() {
el.style.opacity = +el.style.opacity + (new Date() - last) / time;
last = +new Date();
if (+el.style.opacity < 1) {
(window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16)
}
};
tick();
}
</script><a href="http://www.1stlink.com" id="bannerLink" onclick="void window.open(this.href); return false;"><img alt="some text" height="83" id="bannerImage" src="1stimage.jpg" width="633" /> </a>
<p id="p1">this is the first set of rotating text</p>
修改
var images = ["1stimage.jpg","2ndimage.jpg","3rdimage.jpg"];
var descriptions=["this is the first set of rotating text", "Now we have another set of text, in this large paragraph. Write whatever we want here", "and this is the last set of text, we have 3 images. We can add more images and more text."]
var images = ["2ndimage.jpg","3rdimage.jpg","1stimage.jpg"];
var descriptions=["Now we have another set of text, in this large paragraph. Write whatever we want here", "and this is the last set of text, we have 3 images. We can add more images and more text.", "this is the first set of rotating text"]
相关文章:
- 在Widget代码中没有jQuery的情况下,用光标图像从左滑动到右
- 如何在javascript中找到分配给元素的类(没有jQuery)
- 如何在没有jquery的情况下使用Papa Parse
- -webkit转换在JavaScript旋转动画中不起作用(没有JQuery)
- 有人知道有没有jquery插件可以在图像上写文本,并让用户将其放置在图像内的任何位置
- 如何在没有jQuery的情况下模拟按名称命名的事件或解除单个事件的绑定
- 如何在没有表单提交、没有js、没有jquery和没有ajax的情况下将输入的文本框值存储到php变量中
- 如何用javascript发送多个文件没有jQuery我想要每个文件一个进度条
- 如果视图中没有Jquery脚本引用,Unobtrusive Javascript Validation是不起作用的
- 如何在没有JQuery的情况下正确实现无限滚动的AngularJS表
- 如何在没有JQuery的情况下在Javascript中获取文件的内容
- Javascript 滑动图片库 - 没有 jQuery
- Sidr.js相当于没有jQuery的AngularJS
- 如何在没有JQuery的情况下,通过对服务器的基本ajax调用,根据浏览器上的用户活动保持服务器会话活动
- 如何使用AJAX打印PHP POST数据?(没有jQuery)
- Javascript在没有jQuery的情况下获取X父节点
- 如何将DOM元素扩展为类(没有jQuery)
- 如果检查了输入,则将类应用于<身体>,没有jQuery
- 使用ajax提交邮件表单的正确方法?-没有JQuery
- 在没有 jquery 的情况下更改子节点(父节点具有 ID)中的链接文本