Making the entire div clickable

We could make an entire div tag clickable by redirecting the click to a page and by changing the cursor sytle to a pointer. This is good if you want your logo or your banner to be clickable, specially if the logo is embedded together with the banner. Making the entire banner clickable would be very beneficial to your site.

<div onclick=”location.href=’http://www.tildemark.com/’;” style=”cursor: pointer;”>
</div>

Comments

21 Comments on "Making the entire div clickable"

  1. Pedro says:

    this was extremely useful for me, thank you very much =)

  2. Roger says:

    Thank you! helped me a lot!

  3. john says:

    great tip, thanks!

  4. Ali Hussain says:

    Really Good….Thx buddyy…its working

  5. chris says:

    very good code !
    thanks a lot

  6. PALOS says:

    sir… naa kay solo picture ni maam tin2x?…

  7. PALOS says:

    sir … naa kay solo picture ni maam tin2x?

  8. tildemark says:

    you can find pictures of her on facebook. who are you by the way?

  9. Me ha venido muy bien …Thank you Tildemark

  10. Eric Redi says:

    This worked for me, but I had to do some playing around.. here’s the code I used:

    Thanks!

  11. Eric Reid says:

    {div onclick=”location.href=’http://www.YourUrlHere.com/’;” style=”cursor: pointer;”} {div id=”logo”}
    {/div}{/div} –> replace brackets with >

  12. Raymond says:

    Thanks! Just what we needed!!

  13. Unfortunately, this link wont be picked up for seo purposes.

  14. it also doesnt change the status bar onmouseover – the user cant tell where they will be directed to.

  15. Chase says:

    Thanks, easy solution :)

  16. Josh says:

    To make the link open in a new browser window:
    {div onclick=”window.open(‘http://www.mysite.com','_blank‘);” style=”cursor:pointer;”}
    {/div}
    * replace braces “{ }” with “”

  17. Butcher says:

    I cannot use this code! It doesnt work for me!!! Can you please send me instructions on my mail pitlord89[at]hotmail.com
    I have this code:
    {div id=”home”}{/div}
    {div id=”hosting”}{/div}
    {div id=”support”}{/div}
    {div id=”contactus”}{/div}
    {div id=”ordernow”}{/div}
    And when i add you code it becomes>
    {div id=”home”}{div onclick=”location.href=’http://www.tildemark.com/’;” style=”cursor: pointer;”}
    {/div}
    And its not working! Please help!!!

  18. Josh Carey says:

    @Butcher
    You’ll need to add the code to the div itself. Use it like this:
    {div id=”home” onclick=”location.href=’http://www.tildemark.com/’;” style=”cursor: pointer;”}
    {/div}
    It all needs to be 1 div rather than the opening {div id=”home”} then {linking div}

  19. Amitash says:

    It has worked for me. I used it to link the entire div to my facebook page.. Thanks

  20. Thanks for this. I spent a ton of time trying to get the logo image for my blog to be clickable. This made it easy.

  21. Sam says:

    Works for me but i had to have a link in an {a href} tag still because my hover over no longer worked for some reason :/


Here's your chance to leave a comment!