dots Created with Sketch.
Yogesh Chauhan's Blog

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 add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jul 22 Is there a CSS parent selector? #Jul 22 Difference between :where and :is in CSS #Jul 22 Does :is() pseudo selector hint at CSS preprocessing in the future? #Jul 22 Control Scrolling with CSS Scroll Snap #Jul 21 Control rendering using CSS content-visibility property #Jul 21 How to use @supports rule in CSS?
You might also like these
Angular: Templates, directives, data binding, Services and dependency injectionAngularCan Firewall and IDPS Stop DDoS Attack?MiscellaneousWhat’s a Web Storage API in JavaScript?JavaScriptQuick Introduction to 11 Array Iteration Methods in JavaScriptJavaScriptGeneral concepts in DrupalDrupalWhat is Object Mutability in JavaScript?JavaScriptWhat is a component helper function in React?ReactHow to make a Custom Login Page in WordPress?WordPressWhat is IPS(Intrusion Prevention System), How Does It Work and What are the Detection Types?MiscellaneousLearn how to use Self JOIN in SQL and MySQLSQL/MySQLPHP arrays for US states’ full names and abbreviationsPHPSome SQL LIKE Operators We Need to Keep in MindSQL/MySQL