Jump to content


Photo

Changing ID Tags via JS


  • Please log in to reply
2 replies to this topic

#1 All4172

All4172
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 13 March 2006 - 05:23 PM

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.

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 15 March 2006 - 03:18 AM

<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>


#3 All4172

All4172
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 16 March 2006 - 05:56 PM

Thanks for the help, I really do appreciate it. :)

I'll try it out now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users