I\'m developing smartphone hybrid applications.
I\'m trying to hide/show a When I
slideDown
/slideUp
.
I would suggest using on()
instead of bind()
And since youre doing this:
var btnMenuDyn = $('a.btnMenuDyn')
btnMenuDyn
is a jquery dom element, so change this:
if ($(menuDyn).hasClass("menuDynHide"))
to this
if (menuDyn.hasClass("menuDynHide"))
And preferably declare jquery dom elements like this:
var $btnMenuDyn = $('a.btnMenuDyn')
this problem is mobiles do not support click they use touchstart and touchend so can track movement if you still want to test on computers you can do this
$(btnMenuDyn).bind('touchstart mousedown', function(event){
event.preventDefault();
if ($(menuDyn).hasClass("menuDynHide"))
{
$(menuDyn).slideDown().removeClass("menuDynHide");
}
else{
$(menuDyn).slideUp().addClass("menuDynHide");
}
});
another question with same answer jquery touchstart in browser
more infomation can be found at http://backtothecode.blogspot.com/2009/10/javascript-touch-and-gesture-events.html