Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add/Remove Class with jquery function

I have this code.

CSS

body {
    font-family:Verdana, Geneva, sans-serif;
    font-size:14px;
}

.slidingDiv {
    height:300px;
    background-color: #99CCFF;
    padding:20px;
    margin-top:10px;
    border-bottom:5px solid #3399FF;
}

.show_hide {
    display:none; 
}

HTML

<a href="#" class="show_hide">Show/hide</a>
<br />
<div class="slidingDiv">
    Fill this space with really interesting content.
    <a href="#" class="show_hide">hide</a>
</div>

JS

$(document).ready(function(){
    $(".slidingDiv").hide();
    $(".show_hide").show();
    $('.show_hide').click(function(){
        $(".slidingDiv").slideToggle();
    });
});

Someone tell me if its possible to add in this jquery function that if i click on it, at the same time to show/hide a new div, change a class to an tag and remove another class from another tag? How can i do it?

Thanks.

like image 240
bombai Avatar asked Jul 29 '26 17:07

bombai


1 Answers

yes you can, take a look of the method addClass and also of the removeClass.

like image 111
Jorge Avatar answered Aug 01 '26 06:08

Jorge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!