Change onclick content according to page size

1

I'm doing a project that some images have tooltip, but it only appears with the click. The problem is that the mobile version is not legal, so I need to open a new page with the contents of this tooltip. Is there any way to change onclick content according to page size?

Ex:

On the desktop it would be:

<img src="img.jpg" onclick="abre o tooltip" />

And in mobile would be:

<img src="img.jpg" onclick="location.href='abre pagina'" />
    
asked by anonymous 14.08.2014 / 20:30

1 answer

1

You can use it this way

var mq = window.matchMedia( "(min-width: 500px)" ); 
if (mq.matches) {
    // mostra imagem com o tootlip
}
else {
    // mostra imagem com link
}

Source: link

    
14.08.2014 / 21:16