opportunity8888
opportunity8888

Reputation: 23

jQuery Effects - JQuery show and hide div on mouse click

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

Answers (1)

user3127896
user3127896

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

Related Questions