i have many div’s with the same background image and i want change this background when I click the one of them.
I’m training with some like this:
body:
<div id="basket-plusminus"></div>
...
<div id="basket-plusminus"></div>
<script>
$("#basket-plusminus").toggle(
function () {
$(this).addClass("click-plusminus");
},
function () {
$(this).removeClass("click-plusminus");
}
);
</script>
in css:
#basket-plusminus {
width:11px;
height:11px;
background:url(../img/icons/plus-min.png) no-repeat scroll 0 0 transparent;
cursor:pointer;
}
.click-plusminus {
background-image:url(../img/icons/minus-min.png) !important;
}
i don’t know how add the auto id’s in that, mayby this is a sollution.
help
With a little rework of your markup and javascript you could do this: http://jsfiddle.net/Wrxdy/ of course keep the backgrounds you have – I’m just toggling colors for example.