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
https://forums.phpfreaks.com/topic/4854-changing-id-tags-via-js/
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
https://forums.phpfreaks.com/topic/4854-changing-id-tags-via-js/#findComment-17669
Share on other sites

Archived

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

×
×
  • 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.