图像数组不起作用,而此处的文字正在工作

时间:2015-07-16 12:32:17

标签: javascript jquery css slideshow slidetoggle

<!DOCTYPE html>
 <html>
<head>
<style>
#wss{
opacity:0;
-webkit-transition:opacity 1.0s linear 0s;
transition:opacity 1.0s linear 0s;
  }
 </style>
 <script>
 var wss_i = 0;

这个数组不能处理图像,但它正在处理文本我不知道它有什么问题吗?

var wss_array = [
              "<img src="http://www.seizedesign.com/wp-content/uploads/2013/02/e-Commerce-Logo.jpg" /> ",
              "<img src"http://cdn.playbuzz.com/cdn/ff5b7cde-a0bb-4456-93ca-1014f25c063e/58300efe-0336-4287-9ad8-6555e8a9e6c1.jpg"/>",
              "<img src"http://www.golden-gate-park.com/wp-content/uploads/2011/03/conservatory_of_flowers3.jpg"/>",
              "<img src"http://www.robertashton.co.uk/communities/4/004/012/729/184/images/4619952637.jpg"/>",
              ];
   var wss_elem;
   function wssNext(){
    wss_i++;
   wss_elem.style.opacity = 0;
   if(wss_i > (wss_array.length - 1)){
    wss_i = 0;
 }
  setTimeout('wssSlide()',1000);
 }
 function wssSlide(){
 wss_elem.innerHTML = wss_array[wss_i];
 wss_elem.style.opacity = 1;
 setTimeout('wssNext()',2000);
 }
 </script>
</head>
<body>
<span id="wss"></span>
<script>wss_elem = document.getElementById("wss"); wssSlide(); </script>
</body>
</html>

1 个答案:

答案 0 :(得分:4)

\

的数组中使用转义序列"
var wss_array = [
              "<img src=\"http://www.seizedesign.com/wp-content/uploads/2013/02/e-Commerce-Logo.jpg\" /> ",
              "<img src=\"http://cdn.playbuzz.com/cdn/ff5b7cde-a0bb-4456-93ca-1014f25c063e/58300efe-0336-4287-9ad8-6555e8a9e6c1.jpg\"/>",

              ];