-3

I have a div tag with a background image, inside a link tag. What I want to do is highlight or change the relevant background image of the div tag once clicked it.

<td>
  <a href="../pages/index.php">
    <div id="dashboardDiv" 
      style="background:url(../images/home.png) no-repeat center";)>
    </div>
  </a>
</td>
<td></td>

CSS:

#dashboardDiv{
    border:thin;
    float:left;
    height: 133px;
    width: 133px;
}       
Guglie
  • 2,121
  • 1
  • 24
  • 43
EKBG
  • 243
  • 1
  • 8
  • 20

1 Answers1

1

You can style the visited link:

a:visited > #dashboardDiv {
    background-image:url(NEW_URL_HERE) !important;
    /*you can remove !important if you don't style the div inline*/
}

If you want the background to change only when the link is clicked you can use the CSS :clicked pseudoclass instead.

Guglie
  • 2,121
  • 1
  • 24
  • 43