-
help with css switching javascript please
Hello!
I am working with this script below to change background-image style of a html div onclick.
I have three divs, though I want one of the divs to to have the onclick background style by default.
I would greatly appreciate your help. I'm much more of a designer than a coder, and not much of an expert on modifying scripts.
(I've tried a few unfruitful attempts by applying the style to the default and trying to make the script style !important, though I know I'm doing it wrong and there is probably a better method.)
<script type="text/javascript">
var highlightLink = function () {
var active = null, bkgimg = 'url(site_graphics/bkg_gembtn_on.png)';
if (this.attachEvent) this.attachEvent('onunload', function () {
active = null;
});
return function (element) {
if ((active != element) && element.style) {
if (active) active.style.backgroundImage = '';
element.style.backgroundImage = bkgimg;
active = element;
}
};
}();
</script>
here's my html if it will help:
<div id="subview1" onClick="highlightLink(this);">subview1 text<br /></div>
<div id="subview2" onClick="highlightLink(this);"> subview2 text<br /></div>
<div id="subview3" onClick="highlightLink(this);" >subview3 text<br /></div>
thank you much!!!
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks