Jump to content
xisto Community
Sign in to follow this  
fffanatics

Changing Php Classes Using Onclick

Recommended Posts

Hey everyone. I am currently trying to finish my navigation bar on the left side of my website and i am running in to some trouble with the css. I know how to change the items class when a user clicks it using onClick = "this.class = newClass"; but i need to know have to change a different class when a user clicks that link. AKA, how do i get the this part of a class that isnt that current one. For instance if i have a class called subMenu and i want to change it to showSubMenu when a user clicks a link that is of class menu how would i do this not using javascript but just pure css? Thanks for your help because i just cant really find anything good on google for this and it would be awesome to implent this feature on my navigation bar. Thanks again.

Share this post


Link to post
Share on other sites

Ok first of all i screwed up the title. It should be CSS and not PHP. But this is what i want to do without javascript. I want to use the onClick function of the a tag to change the property of a css tag that is not the current links class. Here is an example but it doesnt work:

Styles:

.menu { text-decoration : underline; }.subMenu { display : none; }

<div class="menu" onClick="subMenu.display = block;">Menu</div><div class="subMenu">Submenu</div>

Thus, i need the onClick of menu to change the property of the subMenu css class. Anyone know how to do this? Sorry about the bad explaination on the previous post but it was late and i was frustrated with it and was looking for some help. Ill be sure to try to make my questions clearer from now on. Thanks again.

Share this post


Link to post
Share on other sites

Pretty much except i was hoping to do it without and javascript involved so that it would be compatible with non-javascript enabled browsers. I tried that with javascript disabled and it just went to a different page and that would not work for me since i use includes and you just wont ever get the submenu. I will try to maybe fool with it and see if i can get it to work using part of their style.

Share this post


Link to post
Share on other sites

Like i said i mistitled this topic. However, i would like to thank tyssen for the website link. After messing with their code for like 10 minutes and disabling javascript in my browser, i still was able to get the code to work the way i wanted it to. I realized that if i put it in a link and not just the surrounding div, that if javascript was disabled, it would change the page to the href thus allowing me to use the post a variable to say show this class. Thanks a ton cuase with out that site i probably would have gone crazy trying to figure this out. Thanks again

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.