N1CK3RS0N Posted June 24, 2010 Share Posted June 24, 2010 I'm working on a WYSIWYG editor. I'm not that great with JS at the moment. I'm trying to make the buttons on the toolbar turn a color if they are enabled and then shut off when disabled. For example. If you click bold to enable bold font weight, it will turn the background of the button darker while enabled. Then I want it to return to normal when clicked again to disable the bold font weight. Using "this.style.background" in the function that handles the things onclick works, but I cannot get it to disable when u click again. Quote Link to comment https://forums.phpfreaks.com/topic/205795-on-click-and-unclick/ Share on other sites More sharing options...
Adam Posted June 25, 2010 Share Posted June 25, 2010 You'll need to either preserve the state of the button within a variable, or run a condition on the current background image to determine the new state. Quote Link to comment https://forums.phpfreaks.com/topic/205795-on-click-and-unclick/#findComment-1077088 Share on other sites More sharing options...
KevinM1 Posted June 25, 2010 Share Posted June 25, 2010 jQuery has a very nice toggle function that will do what you want: http://api.jquery.com/toggle/ Quote Link to comment https://forums.phpfreaks.com/topic/205795-on-click-and-unclick/#findComment-1077136 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.