Is it possible to disable tooltips based on the screen size of the device?

I have implemented tooltips on a website and they work great on the desktop. But they are problematic for small devices. By clicking on the link on a small screen device without the hover function, you simply pick up a hint, rather than go to the link. Is there a way to disable or disable tooltips for small devices, perhaps using some jquery code verification?

+4
source share
2 answers

You can check for touch events before invoking init on bootstrap tooltip. This will allow you to disable the feature tooltipfor most touch devices, not just thinner touch screen devices such as mobile phones.

if(!('ontouchstart' in window))
{
  $('#example').tooltip(options); // <-- Example code from Bootstrap docs
}
+11
source

Maybe something like this:

if ( $(window).width() < 780 ){
    $('#element').tooltip('destroy');
}
+1
source

Source: https://habr.com/ru/post/1536354/


All Articles