simple swapping of image won't work? (2 posts)

  1. Redeye Adaya
    Posted 6 years ago #

    Have a div that already changes its background onmouseover and onmouseout which was done through simple CSS. Now I want to add an effect that when the div gets clicked it retains the image used onmouseover. I implemented it via javascript but I can't seem to make it work. It only removes the default bg. Here's my code:
    div html:

    <div id="content_1_1" onclick="changeBg(this.id)">


    function changeBg(content){
    document.getElementById(content).style.backgroundImage = "url(images/itembg_on.jpg)";

    Any help would be greatly appreciated...

  2. Michael
    Part-Time Forum Moderator
    Posted 6 years ago #

    depending on from where you call the function, the image path is probably not correct - try:

    "url(<?php bloginfo('template_url'); ?>/images/itembg_on.jpg)"

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.