I am doing slideToggle as follows:
$(document).ready(function(){
$("#show_morecats").click(function(){
$("#morecats").slideToggle("slow");
$("#show_morecats").css("background-color","#399C05");
});
});
HTML
<a href="#" id="show_morecats">More</a>
<div id="morecats" style="display:none;">Some text</div>
Now I want when I click More
link then morecats
div will open with a slide effect and the color of more
link will be red and when again click on more
link then it will be closed and color of link will be blue.
SlideToggle is working quite fine, but coloring of link is not working correctly. I dont want to put :visible condition, because I know there is a function in jquery which does the same, toggle your div and same time will toggle the class or css of the main element, but what that exact function and how to use it. I googled about it but didn't get anything.
Can anyone please suggest me the shortest way to solve this toggling problem.