Reputation: 23
I have one script for (Show and hide div #id on click )and everything work fine only what i need to know how can change font color for (Click Here) on click mean if hide (div class="menu") the Click Here text color will be black / if show (div class="menu") the Click Here text color will be the color red
Image for more clarify
http://s18.postimg.org/5f9in18u1/image.jpg
div id="showmenu">Click Here</div>
<div class="menu" style="display: none;"><ul><li>Button1</li><li>Button2</li><li>Button3</li></ul></div>
Script below
$(document).ready(function() {
$('#showmenu').click(function() {
$('.menu').slideToggle("fast");
});
});
Demo / http://jsfiddle.net/APA2S/1/
Upvotes: 2
Views: 266
Reputation: 6573
All that you need is toggleClass
function. Take a look at this Fiddle
$(document).ready(function() {
$('#showmenu').click(function() {
$('.menu').slideToggle( 'fast' );
$('#showmenu').toggleClass( 'color' );
});
});
Upvotes: 1