I have a boolean variable called isTouchscreen and some on(‘hover’, …) events. If the isTouchscreen boolean variable equals true then I need to change on(‘hover’) events to on(‘click’) events. Is this possible?
Something like:
$(".smart-suggestions").on("hover", ".option", function(){
$('.img-container img').show();
//and do more stuff....
});
if(touchscreen==true){
//change onhover event to onclick event
}
you could do it this way:
Alternate approach if you need both events :