문제

I'm using a script for a touch swipe left hand sliding nav. How do I go about getting the nav to have the open toggle position when the page loads (instead of it being closed).

<script>
$(window).load(function(){
$("[data-toggle]").click(function() {
var toggle_el = $(this).data("toggle");
$(toggle_el).toggleClass("open-sidebar");
});

$(".swipe-area").swipe({
swipeStatus:function(event, phase, direction, distance, duration, fingers)
{
if (phase=="move" && direction =="right") {
$(".container").addClass("open-sidebar");
return false;
}
if (phase=="move" && direction =="left") {
$(".container").removeClass("open-sidebar");
return false;
}
}
}); 
});
</script>
도움이 되었습니까?

해결책

In your html :

<div class="container open-sidebar"> 
  [content]
</div>

or in your Js :

$(window).load(function(){
  $(".container").addClass("open-sidebar"); // add class ".open-sidebar" to ".container" once dom is loaded
  $("[data-toggle]").click(function() {
  ...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top