Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/449.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 HTML上的滑动事件_Javascript_Html_Css_Jquery Mobile - Fatal编程技术网

Javascript HTML上的滑动事件

Javascript HTML上的滑动事件,javascript,html,css,jquery-mobile,Javascript,Html,Css,Jquery Mobile,我正在尝试创建一个滑动事件,在第1页它可以滑动到第2页,但是在第2页它不工作,这里有什么问题?它只在第一页有效,我该怎么办? (页面主要是代码,我需要更多字符) 我正在尝试创建一个滑动事件,在第1页它可以滑动到第2页,但是在第2页它不工作,这里有什么问题?它只在第一页有效,我该怎么办 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=devi

我正在尝试创建一个滑动事件,在第1页它可以滑动到第2页,但是在第2页它不工作,这里有什么问题?它只在第一页有效,我该怎么办? (页面主要是代码,我需要更多字符) 我正在尝试创建一个滑动事件,在第1页它可以滑动到第2页,但是在第2页它不工作,这里有什么问题?它只在第一页有效,我该怎么办

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).on("pagecreate","#page1",function(){
  $("p").on("swiperight",function(){
    $('#page1').fadeOut();
    $('#page2').fadeIn();
    $('#page3').fadeOut();
  });                       
});
$(document).on("pagecreate","#page2",function(){
  $("p").on("swiperight",function(){
    $('#page1').fadeOut();
    $('#page2').fadeOut();
    $('#page3').fadeIn();
  });                       
});
$(document).on("pagecreate","#page3",function(){
  $("p").on("swiperight",function(){
    $('#page1').fadeOut();
    $('#page2').fadeOut();
    $('#page3').fadeIn();
  });                       
});
</script>
</head>
<body>

<div data-role="page" id="page1">
  <div data-role="main" class="ui-content">
    <p style="border:1px solid black;margin:5px;">PAGE 1</p>  
  </div>
</div> 
<div data-role="page" id="page2">
  <div data-role="main" class="ui-content">
    <p style="border:1px solid black;margin:5px;">PAGE 2</p>  
  </div>
</div> 
<div data-role="page" id="page3">
  <div data-role="main" class="ui-content">
    <p style="border:1px solid black;margin:5px;">PAGE 3</p>  
  </div>
</div> 

</body>
</html>

$(document).on(“pagecreate”,“#page1”,function()){
$(“p”)。在(“swiperight”,函数()上{
$(“#第1页”).fadeOut();
$('page2').fadeIn();
$('#第3页').fadeOut();
});                       
});
$(document).on(“pagecreate”,“#page2”,function()){
$(“p”)。在(“swiperight”,函数()上{
$(“#第1页”).fadeOut();
$(“#第2页”).fadeOut();
$('page3').fadeIn();
});                       
});
$(document).on(“pagecreate”,“#page3”,function()){
$(“p”)。在(“swiperight”,函数()上{
$(“#第1页”).fadeOut();
$(“#第2页”).fadeOut();
$('page3').fadeIn();
});                       
});
第1页
第2页
第3页
$(document).on(“pagecreate”,“page1”,function(){
控制台日志(“第1页”);
$(“#p1”)。在(“SwiperRight”,function()上{
控制台日志(“第1页的p”);
//$(“#第1页”).fadeOut();
$(“#第1页”).fadeOut();
$('page2').fadeIn();
$('#第3页').fadeOut();
});                       
});
$(“#p2”)。在(“SwiperRight”,function()上{
控制台日志(“第2页的p”);
$(“#第1页”).fadeOut();
$(“#第2页”).fadeOut();
$('page3').fadeIn();
});                       
$(“#p3”)。在(“SwiperRight”,function()上{
控制台日志(“第3页的p”);
$('#第1页')。淡出;
$('#第2页')。淡出;
$('第3页').fadeIn;
});                       

第1页

第2页

第3页


@Steven S如果有助于解决您的问题,请不要忘记投票并接受答案。如果要以编程方式从一页切换到另一页,请使用