【发布时间】:2015-01-27 22:40:28
【问题描述】:
我正在尝试为移动版本制作一个响应式滑块。 网站是使用 Angular JS 开发的。 当我尝试集成 JQuery 滑块时,由于 Bootstrap CSS 文件,整个站点都处于干扰状态。 因此,在那部分中,我创建了一个纯 Javascript 代码。以及如何使这些图像具有响应性。 下面我添加代码。
<head>
<script type="text/javascript">
var slideimages = new Array() // create new array to preload images
slideimages[0] = new Image() // create new instance of image object
slideimages[0].src = "images/slide/1.jpg" // set image object src property to an image's src, preloading that image in the process
slideimages[1] = new Image()
slideimages[1].src = "images/slide/2.jpg"
slideimages[2] = new Image()
slideimages[2].src = "images/slide/2.jpg"
</script>
</head>
<body>
<a href="javascript:slidelink()"><img src="firstcar.gif" id="slide" width=100 height=56 /></a>
<script type="text/javascript">
//variable that will increment through the images
var step = 0
var whichimage = 0
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.getElementById('slide').src = slideimages[step].src
whichimage = step
if (step<2)
step++
else
step=0
//call function "slideit()" every 2.5 seconds
setTimeout("slideit()",2500)
}
function slidelink(){
if (whichimage == 0)
window.location = "#"
else if (whichimage == 1)
window.location = "#"
else if (whichimage == 2)
window.location = "#"
}
slideit()
</script>
【问题讨论】:
-
document.location = "https://www.google.nl/webhp?tab=ww&ei=d8p5VPSTLMfkUpf7gpgE&ved=0CAkQ1S4#safe=off&q=How+to+add+a+class+in+javascript"
标签: javascript jquery html css angularjs