Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 幻灯片放映暂停按钮不显示';行不通_Javascript_Jquery_Asp.net_Web Applications_Jquery Cycle - Fatal编程技术网

Javascript 幻灯片放映暂停按钮不显示';行不通

Javascript 幻灯片放映暂停按钮不显示';行不通,javascript,jquery,asp.net,web-applications,jquery-cycle,Javascript,Jquery,Asp.net,Web Applications,Jquery Cycle,这是一个幻灯片放映,我的问题是“暂停”按钮不起作用,也不暂停幻灯片放映。firebug中没有任何错误。按钮更改为“继续”,但不暂停幻灯片放映。 我真的非常感谢你的帮助 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm6.aspx.cs" Inherits="WebApplication4.WebForm6" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML

这是一个幻灯片放映,我的问题是“暂停”按钮不起作用,也不暂停幻灯片放映。firebug中没有任何错误。按钮更改为“继续”,但不暂停幻灯片放映。 我真的非常感谢你的帮助

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm6.aspx.cs" Inherits="WebApplication4.WebForm6" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
<script 
src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
  <script type="text/javascript" src="cycle.js"></script>

 <script style="text/javascript">
     $(function () {
         $('.slider img:gt(0)').hide();/*hides first 2th 3th pics*/
         setInterval(function () {
             $('.slider :first-child').fadeOut()
         .next('img').fadeIn()
         .end().appendTo('.slider');
         },
      3000);
     });

     $(document).ready(function ($) {

         $('#playbutton').click(function () {
             $(this).css('margin-left', '-9999px');
             $('#pausebutton').css('margin-left', 0);
         });

         $('#pausebutton').click(function () {
             $(this).css('margin-left', '-9999px');
             $('#playbutton').css('margin-left', 0);
         });

     });

     $(document).ready(function ($) {$('#playbutton').click(function() { 
    $('#mg').cycle('resume'); 
}); });

$(document).ready(function ($) {$('#pausebutton').click(function() { 
    $('#mg').cycle('pause');
});
});
 </script>



    <style type="text/css">
        .slider
        {
           position:fixed; 
            width:750px; 
            height:400px; 
            background-color:white; 
            top: 9px; left: 12px; z-index:-1; 
            background:transparent url(loading.gif) no-repeat 50% 50%;
        }
         .slider img {
        border-style: none;
            border-color: inherit;
            border-width: medium;
            position:fixed;

            top: 42px;
            left: 50px;
            height: 220px;
            width: 651px;
            bottom: 267px;
        }
       #pausebutton {
    left: 356px;
    margin-left:0px;
    position:absolute;
            top: 273px;
            height: 27px;
        }
#playbutton {
    left: 356px;
    margin-left:0px;
    position:absolute; top: 273px;
            height: 27px;
}

    </style>



</head>
<body >

      <div class="slider" id="mg" >
                    <img src="slider-2.jpg"  /> 
                    <img src="slider-3.jpg"  />
                    <img src="slider-4.jpg"  />       
               </div >

<a href="#" id="playbutton"><img src="play.png" alt="play button" title="Play" /></a> 

<a href="#" id="pausebutton" ><img src="pause.png" alt="pause button" title="Pause" /></a> 




</body>
</html>

$(函数(){
$('.slider img:gt(0)').hide();/*隐藏前2张和第3张图片*/
setInterval(函数(){
$('.slider:first child').fadeOut()
.next('img').fadeIn()
.end().appendTo('.slider');
},
3000);
});
$(文档).ready(函数($){
$(“#播放按钮”)。单击(函数(){
$(this.css('margin-left','-9999px');
$('#pausebutton').css('margin-left',0);
});
$(“#暂停按钮”)。单击(函数(){
$(this.css('margin-left','-9999px');
$('#playbutton').css('margin-left',0);
});
});
$(文档).ready(函数($){$('#播放按钮')。单击(函数(){
$('#mg')。循环('恢复');
}); });
$(文档).ready(函数($){$('#pausebutton')。单击(函数(){
$('mg')。循环('pause');
});
});
.滑块
{
位置:固定;
宽度:750px;
高度:400px;
背景色:白色;
顶部:9px;左侧:12px;z索引:-1;
背景:透明url(loading.gif)不重复50%50%;
}
.滑块img{
边框样式:无;
边框颜色:继承;
边框宽度:中等;
位置:固定;
顶部:42px;
左:50px;
高度:220px;
宽度:651px;
底部:267px;
}
#暂停按钮{
左:356px;
左边距:0px;
位置:绝对位置;
顶部:273px;
高度:27px;
}
#播放按钮{
左:356px;
左边距:0px;
位置:绝对;顶部:273px;
高度:27px;
}

我认为您需要停止
标记的默认行为,因为单击它将导致页面刷新

$('#pausebutton').click(function(e) {
    e.preventDefault();
    $('#mg').cycle('pause');
});

我认为您的代码有逻辑错误,因为当firebug没有任何错误时,它表明您的代码没有任何语法错误。请尝试使用firebug调试您的代码或再次检查您的代码。另一件事是在多个浏览器中测试您的代码大多数情况下java脚本代码在所有浏览器中都不起作用。

也许在您试图调用它的任何对象上都不存在
cycle
函数?在我看来,它非常像
$(“#mg”)
是一个普通的
div
。如果控制台中没有任何JavaScript错误,任何回答的尝试都将是在黑暗中进行的。你可能想发布一个链接,让人们看看这个例子。这将帮助你得到一个完整的答案。你的意思是我该怎么做?我的意思是你能在有问题的页面上发布一个公共链接,以便其他人可以查看吗?