So, I am making a website and I wanted to make the div clickable, instead of using the anchor tag.
I did it like this: <div onClick="location.href='URL';"
and it worked, but I want it to open the URL in a new page. I tried adding target="_blank"
but unfortunately it didn't work.
Does anyone know how to do it or if it's possible at all?
CodePudding user response:
<div onClick="window.open('URL', '_blank').focus();"></div>