javascript - Custom swiper not working for body -
i wrote custom swiper alerts. code in link.
when swipe left right or right left, gives alerts successfully.
here, i've used div swiping action. code this:
<div id="test" class="text-center"></div> <script> $(document).ready(function() { $(".text-center").swiperight(function() { /*$("#mycarousel").carousel('prev'); */ alert("swiped right"); }); $(".text-center").swipeleft(function() { /*$("#mycarousel").carousel('next'); */ alert("swiped left"); }); }); </script> if change id body this,
<style type="text/css"> #test{ position: absolute; background-color: #0067ac; width:100%; height:500px; } .text-center{ position: relative; margin-right: 3%; margin-top: 5%; } <body id="test" class="text-center"> <script type="text/javascript"> $(document).ready(function() { $("#test").swiperight(function() { /*$("#mycarousel").carousel('prev'); */ alert("swiped right"); }); $("#test").swipeleft(function() { /*$("#mycarousel").carousel('next'); */ alert("swiped left"); }); }); </script> then swiping works. link here.
if apply code, doesn't work body tag . code is:
<div id = "maindiv" class = "container" style="padding:0px;width:100%;height:100%"> <div id = "header"> <span id = "icons"> <span id = "menu"></span> <span onclick="goback()" id = "back"></span> </span> <span id = "title"> <span id="junos"> junos </span><span id = "genius">genius</span> </span> </div> <div id ="body" class="container-fluid" style="position:relative;"> <!-- <div id="swiper"> --> <div id="searchmenu" class="col-xs-4" style="height:400px; overflow-y:auto;padding:0px;display:none;min-width: 250px;background-color:transparent;"> </div> <p class="text-center" onclick="goback()" style="padding-top:12px;">help</p> <!-- start --> <ul class="list=unstyled text-justify" style="margin-right:20px;"> <li> junos genius fun way improve skills juniper networks junos operating system , prepare technical certification. application virtual flashcard reader includes decks of multiple choice questions several junos-based exams including jncia-junos, jncis-ent, jncis-sec, , jncis-sp. answer multiple-choice questions , immediate feedback on accuracy of answer. </li> <li> questions may answered in study mode, timed test mode, or challenge instructor mode. </li> <ul> <li> in study mode, choose question category interests , begin answering questions. system not track score , no achievements earned correct answers. </li> <li> enter timed test mode, choose question category , tap timed test. simulate live exam , provide 60 minutes answer 60 questions selected @ random among categories in deck. see percentage correct score on completion of 60 questions or @ end of 60 minutes (whichever comes first). </li> <li> enter challenge instructor mode, choose question category tap challenge instructor challenge ranks of instructors. score higher on category instructor earn device achievement. device achievements specific question category. instructors should challenged, , beaten, repeatedly earn higher quantities of device achievements use in ‘my network’. beating instructors becomes progressively more difficult work through ranks. </li> </ul> <li>my network: device achievements (earned beating instructors in challenge instructor mode) used build network views in handy network drawing tool called network. juniper networks devices earned available addition network view. able add lan segments, wan segments, , end user devices including laptops, printers, , servers network view. , have ability share network diagram through email or social media.</li> </ul> <!-- end --> </div> </div> #maindiv { background-image: url("../junosimages/mob/junos_genius_p_960x720_question_blank_phone.jpg"); background-repeat: no-repeat; background-size: 100% 100%; height: 100%; width: 100%; } /*custom js*/ $(document).ready(function() { $("#maindiv").swiperight(function() { alert("swiped right"); }); $("#maindiv").swipeleft(function() { alert("swiped left"); }); });
this problem css.
i updated css , worked fine :
check out fiddle plunker code
css updations here:
<style type="text/css"> #test{ position: absolute; background-color: #0067ac; width:100%; height:500px; } .text-center{ position: relative; margin-right: 3%; margin-top: 5%; } </style>
Comments
Post a Comment