Answer the question
In order to leave comments, you need to log in
How to map hover to touchstart?
Hello. The site has a menu with pop-up child sub-menus when hovering over the main menu. popup is done like this:
$('.menu-fallback').hover(function () {
$(this).find('.fallback').stop().slideDown('fast')
$(this).addClass('active');
}, function () {
$(this).find('.fallback').stop().slideUp('fast');
$(this).removeClass('active');
});
$('.menu-fallback').hover(function () {
if ($(this).hasClass('active')){
//Если уже выделено
}
else{
// Если нету класса active
$(this).find('>a').click(function(e){
e.preventDefault();
});
}
$(this).find('.fallback').stop().slideDown('fast')
$(this).addClass('active');
}, function () {
$(this).find('.fallback').stop().slideUp('fast');
$(this).removeClass('active');
});
Answer the question
In order to leave comments, you need to log in
Use:
function is_touch_device() {
return !!('ontouchstart' in window);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question