Jump to content

Archived

This topic is now archived and is closed to further replies.

All4172

Changing ID Tags via JS

Recommended Posts

I have a menu when a user clicks on a Link, its opens up data below. I do this by using the following code:

<id=navlist><a href=# onclick="show('screen_shots');return false;">.

My question is, how can I modify this so where it not only does what it currently does, but also when a user clicks on the link above, it'll change the CSS ID from navlist to current. Then when a user clicks on another link, it'll go back from current to navlist. Any ideas would be greatly appreciated as my knowledge of JS is very limited.

Share this post


Link to post
Share on other sites
[code]<script type="text/javascript">
    var c = '';
    
    function changeme(w, e) {
        c.className = "navlist";
        e.className = "current";
        c = e;
        //show(w);
    }
</script>
<style>
.navlist {
    background-color: #0099CC;
}
.current {
    background-color: #999933;
}
</style>

<div class="navlist"><a href="#" onclick="javascript: changeme('screen_shots', this);">Menu Item 1</a></div>
<div class="navlist"><a href="#" onclick="javascript: changeme('screen_shots', this);">Menu Item 2</a></div>
<div class="navlist"><a href="#" onclick="javascript: changeme('screen_shots', this);">Menu Item 3</a></div>
<div class="navlist"><a href="#" onclick="javascript: changeme('screen_shots', this);">Menu Item 4</a></div>
<div class="navlist"><a href="#" onclick="javascript: changeme('screen_shots', this);">Menu Item 5</a></div>
<div class="navlist"><a href="#" onclick="javascript: changeme('screen_shots', this);">Menu Item 6</a></div>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.