Rommeo Posted November 16, 2009 Share Posted November 16, 2009 In my left menu I have css-buttons my css file is like; #button {} #button li {} #button li active {} and in my html file I m using those buttons like : <li><a href="Support.html">Support</a></li> <li><a id="active" href="Order.html">Order</a></li> here is my problem, if you notice the second line "id" is "active" here. I m activating it by using php <li><a id="<?php if($page=='order') echo "active"; ?>" href="Order.html">Order</a></li> But since I have a long menu, I need to use if statement more than 30 times. So I m looking for easier and faster solution. So is it possible to change the "id" of the anchor via javascript ? like : <a href="www.etc.com/order" onClick="this.id=active">Order</a> I need your ideas, other options are also welcome. Just trying to find easier and quicker way. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted November 17, 2009 Share Posted November 17, 2009 I dont know if this would be a solution for you or not but instead of changing the id I would just add and remove classes. If you have an active class you can just assign it and remove it as needed. Quote Link to comment Share on other sites More sharing options...
Rommeo Posted November 17, 2009 Author Share Posted November 17, 2009 I dont know if this would be a solution for you or not but instead of changing the id I would just add and remove classes. If you have an active class you can just assign it and remove it as needed. Can you give me an example ? How will I change the active class ? via JavaScript ? How ? Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted November 17, 2009 Share Posted November 17, 2009 just like you were trying to do with the id's but I believe it is className. sorry forgot alot about regular javascript now that i use jquery all the time. Example: <a href="javascript:void(0);" onClick="this.className='active'">here</a> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.