0

I need to remove borders and make them reappear after a bit, but 2 css methods do not work one after another somehow.

$(".item").click(function() {
    $(this).css({
      "border-left": "none",
      "border-bottom": "none"
    });

    var that = this;

    var returnBorder = window.setTimeout(function() {
      $(that).css({
        "border-left": "solid 3px #0086b3;",
        "border-bottom": "solid 3px #0086b3;"
      });
    }, 500);
  });
1
  • both css left and bottom will be executed at the same time Commented Mar 5, 2017 at 7:28

1 Answer 1

1

Check this,

$(".item").click(function() {
    $(this).css({
      "border-left": "none",
      "border-bottom": "none"
    });

    var that = $(this);

    setTimeout(function() {
      $(that).css({
        "border-left": "solid 3px #0086b3",
        "border-bottom": "solid 3px #0086b3"
      });
    }, 2000);
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='item' style='width: 100px; height:100px;display:block;border: solid 1px black'>
    test
    </div>

Problem in your code is, you have given ; in applying css in js code, which js gives by default, so you dont need to give that.
I have removed it from my code.

Give it a try, this will work.

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

2 Comments

Oh God! I see! Thank you!
Your most welcome! If your problem has been solved by my answer, you can accept my answer !

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.