jquery click function always fires on second click -


i have click function in combination cookie.js:

$("#mobilebar").show();      var cs = $.cookie("sidebar");     if(cs == "close") {         $(".sidebar").css("left", "-44px");         $("#mobilebar")                     .css("left","0px")                     .addclass("active");         $(".sidecontent")                     .css("left","-225px")                     .hide();     }  $("#mobilebar").on("click", function(){         var $theelem = $(this);         if (!$theelem.attr('data-toggled') || $theelem.attr('data-toggled') == 'off') {             $theelem.attr('data-toggled','on')                    .animate({left: "0px"})                    .addclass("active");             $.cookie("sidebar", "close", { expires: 7, path: "/" });             $(".sidebar").animate({left: "-44px"});             $(".sidecontent")                    .css("left","-225px")                    .hide();          } else if ($theelem.attr('data-toggled') == 'on'){              $.removecookie("sidebar");             $(".sidecontent")                     .css("left","-225px")                     .hide();             $(".sidebar").animate({left: "0px"});             $theelem.animate({left: "33px"})                      .removeclass("active")                      .attr('data-toggled','off');         }     }); 

the #mobilebar visible on ipad, iphone etc.

i have tested function on desktop too, fires on second click or second tap.

live click not fire on first action.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -