0

I have this code

<script type="text/javascript">
$(document).ready(function() {
     $(".slide_nav").click(function() {
         $(".big_slide_in").toggleClass("active");
         $("#headerMover").toggleClass("left_off");
         $(".big_slide").toggleClass("background");
     });

});
</script>

so I want to click on the class "background" would erase class "active" and "left_off"? Thank you so much!

I am not speak english, sorry.

4
  • Do you mean click on an object with class background? Or are you saying that you click on slide_nav which has a class called background? Commented May 30, 2015 at 3:17
  • No, I want to click on the class "background" would erase class "active" and "left_off" Commented May 30, 2015 at 3:21
  • 2
    What do you mean by "click on the class "background"? Do you mean clicking on an object which has css class set to "background"? Commented May 30, 2015 at 3:40
  • Please read How do I ask a good question? before attempting to ask more questions. Commented Jun 26, 2017 at 19:03

1 Answer 1

1

You can try

$(document).ready(function () {
    $(".slide_nav").click(function () {
        $(".big_slide_in").toggleClass("active");
        $("#headerMover").toggleClass("left_off");
        $(".big_slide").toggleClass("background");
    });

    $(".big_slide").click(function () {
        //check if background class is added
        if ($(this).hasClass('background')) {
            $(".big_slide_in").removeClass("active");
            $("#headerMover").removeClass("left_off");
        }
    });
});

Demo: Fiddle

Sign up to request clarification or add additional context in comments.

2 Comments

no, i mean: When i click to "slide_nav" -> "big_slide_in" add "active", "#headerMover" add "left_off", "big_slide" add "background". Then i click to "background" -> "big_slide_in" remove "active", "#headerMover" remove "left_off", "big_slide" remove "background". Thanks!
@MCN what do you mean by background... do you mean the big_slide element - jsfiddle.net/arunpjohny/jn8zzLjm/2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.