1

I've seen the following code:

$(this).css('border-color', '');

and wonder whether it is the same as:

$(this).css('border-color', 'none');

or whether in the first case the border-color CSS property is simply reset to its default value from the CSS stylesheet (and if not, then is there a way to reset the value to whatever is default in the stylesheet?). My concern is that I shouldn't have to change the jQuery JavaScript when I change the border-color in the stylesheet. Things should happen automatically.

1
  • Setting the property to an empty string works, but in older versions of Internet Explorer (up through IE9) it behaved badly. Commented Sep 13, 2015 at 13:19

1 Answer 1

5

Setting the css value to none is literally setting it to none in css. Setting it to an empty string removes the property from the style attribute on the tag.

<div style="border-color: none;"></div>

vs

<div style></div>

The reason you'd use none is if you want to overwrite an existing style that sets border-color to something. If you remove the style from the style attribute then it will fall back to an already defined style for border-color if it exists.

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

1 Comment

This is correct, but things don't work well in old versions of IE.

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.