how to make an image as a clickable link to another html page using javascript?

this is the js code I wrote :

var goToSecondPage= document.querySelector('.mobile');

goToSecondPage.addEventListener("click", function() {

document.location.href='productDetails.html';
 })

I’m trying to use an image in an existed class on an index html page (called mobile) and make it as a clickable link image to another html file called “productDetails.html”