JavaScript Answers

How to make a div into a link with JavaScript?

Spread the love

To make a div into a link with JavaScript, we can make it navigate to a URL on click.

For instance, we write

  style="cursor: pointer"

to make the div navigate to on click by setting location.href to '' in the onclick attribute.

And we set the cursor style to pointer to change the cursor to a pointer when we move our mouse over the div.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *