Skip to content
Fix Code Error

How can I remove a style added with .css() function?

March 13, 2021 by Code Error
Posted By: Anonymous

I’m changing CSS with jQuery and I wish to remove the styling I’m adding based on the input value:

if(color != '000000') $("body").css("background-color", color); else // remove style ?

How can I do this?
Note that the line above runs whenever a color is selected using a color picker (ie. when the mouse moves over a color wheel).

2nd note: I can’t do this with css("background-color", "none") because it will remove the default styling from the CSS files.
I just want to remove the background-color inline style added by jQuery.

Solution

Changing the property to an empty string appears to do the job:

$.css("background-color", "");
Answered By: anon

Related Articles

  • Creating all possible combinations in a vector from 0 to 5…
  • Is CSS Turing complete?
  • Matplotlib Deprecation Warning : The is_first_col function…
  • What is the easiest way to remove the first character from a…
  • Active tab issue on page load HTML
  • Form field border-radius is not working only on the last…
  • Polymer 1.x: Observers
  • How do I keep only the first map and when the game is…
  • Is it possible to apply CSS to half of a character?
  • How to sum each table of values in each index produced by…

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Oracle SQL: Update a table with data from another table

Next Post:

How do you get a list of the names of all files present in a directory in Node.js?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error