YogeshChauhan . com

How to change CSS with jQuery?

in CSS & jQuery on August 23, 2020

We can add, remove or change CSS property values with jQuery just like we can with JavaScript.

Just change it directly.

Easier to target the element than JavaScript.

$('#ID_name').css('padding', '2%');

Change more than one properties

 margin: "2%",
 padding: "10px",
 color: "green"

Properties with quotes

We can use CSS rules that have hyphens in them (i.e. font-size) OR we can put them in quotes or camel-case the style rule name.

 "background-color": "blue",

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to uninstall Cocoapods from the Mac OS? #4 How to add Read More Read Less Button using JavaScript? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

May 5 Use inline if to make a shorter conditional syntax in React May 4 What is Conditional Rendering in React? May 3 How does @extend rule work in SCSS (Sass)? May 2 How different is Handling Events in React vs HTML DOM? May 2 How to create bouncing balls using HTML canvas and JavaScript? Apr 30 HTML canvas methods

You might also like these

LEFT JOIN in PostgresPostgresHow to remove special characters (dash, asterisk etc) from any string in PHP?PHPHow to create a cross-browser smooth scrolling with jQuery?jQueryForcing the domain to serve securely using HTTPSMiscCSS backface-visibility PropertyCSSHow to create a sticky menu pin using CSS?CSSHow to make flexbox items of the same size?CSSHow to Skip or Exclude a Specific URL or File From .htaccess Rewrite Rule?PHPHow to verify your domain in Google Console with a TXT record?MiscHow to check if the element exists using JavaScript and jQuery?JavaScriptValues and Types Basics in JavaScriptJavaScriptIs monitoring an employee’s work on a computer a desirable or undesirable activity?Misc