Jump to content

Changing ID Tags via JS


All4172

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.
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.