Jump to content

Help


Recommended Posts

So example i have a div

 

<div id="mydiv"></div>

 

i add a data attr to it.

 

<div id="mydiv" data-url="http://google.com"></div>

 

as you can see, the data have a url in it. I would like it to go to google.com if the div is clicked.

 

how do i do it with the javascript

 

currently the code i have

<script>
function redirect() {
var tdiv = getElementbyId('mydiv');
var rurl = tdiv.getAttribute('url');
location.href = rurl ;
}

Link to comment
https://forums.phpfreaks.com/topic/238862-help/#findComment-1227373
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.