PDA

View Full Version : How a div can be made clickable


freiheit
11-11-2009, 03:53 AM
I am interesten in making my header div clickable.
I have heard this can be made with java script but i couldnt finally figer it out how to do it.

Can someone help me with this?

I found that a div can be made clickable using this line of code below

<div onclick="location.href='http://www.yourwebsite.com/';" style="cursor: pointer;"></div>

But i have no idea where to put that.

Thanks in advance

Dani Chankhour
11-11-2009, 10:38 AM
In the sculptor page you should have something like:

<div id="header"></div>

All you have to do is add the onClick event to the div so it look something like this:

<div id="header" onclick="location.href='http://www.yourwebsite.com/';" style="cursor: pointer;"></div>

Let me know if you still have any other questions.

Cologne
11-19-2009, 11:04 AM
Thast nice.

Is it possible to give the div an other bachgroundcolor if mouse is over?




I do it with the <a href="dfgdfgdgdfgdfg" class="link"><div class="box"></div></a>

.link a = red

.link a:hover = green

Dani Chankhour
11-19-2009, 08:51 PM
Usually your a tags are wrapped in a div tag. So your code should look something like this:

<html><head>
<style>
.box a:hover {
background-color:#F00;
font-size:18px;
}
</style>
<title>Untitled Document</title>
</head><body><div class="box"><a href="">Test</a></div></body></html>