{"id":7762,"date":"2015-10-21T16:15:21","date_gmt":"2015-10-21T13:15:21","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=7762"},"modified":"2017-12-21T15:52:12","modified_gmt":"2017-12-21T13:52:12","slug":"jquery-css-addremove-style-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/","title":{"rendered":"jQuery CSS add\/remove Style Example"},"content":{"rendered":"<p>The aim of this example is to show how you can manipulate CSS, add or remove styling from elements in a dynamic manner, made possible by the famous JS library, jQuery. <\/p>\n<p>Now jQuery offers reliable ways to select elements and apply methods, which basically means that what we want to do, shall be found inside a method, and it is true. <\/p>\n<p>For most of the article, we&#8217;ll make use of <code>.css()<\/code> method, which is our key to all CSS properties that can be applied with just a slightly different syntax inside the brackets. Follow along with simple and then more complex application of CSS manipulations.<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;qGGDqWnle19VavkM&#8217;]<\/p>\n<h2>1. Document Setup<\/h2>\n<p>To begin, create a new HTML document and add the following basic syntax inside like so:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;title&gt;jQuery CSS Example&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;!-- HTML SECTION  --&gt;\r\n\r\n\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script src=\"jquery-1.11.3.min.js\"&gt;&lt;\/script&gt;\r\n\r\n&lt;script type=\"text\/javascript\"&gt;\r\n\r\n&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Note that the jQuery library is linked locally. If you don&#8217;t have the downloaded file, you can find it <a href=\"https:\/\/jquery.com\/download\/\" target=\"_blank\">here<\/a>.<\/p>\n<h2>2. Know the Basics<\/h2>\n<p>In this section we&#8217;ll consider the most basic syntax and application of the <code>.css()<\/code>, which is of essential improtance.<\/p>\n<h3>2.1 Syntax<\/h3>\n<p>The basic syntax of the method is: <\/p>\n<p>1. <code>.css( propertyName )<\/code> where the <strong>propertyName<\/strong> is of type <strong>String<\/strong> and contains a single CSS property.<\/p>\n<p>2. <code>.css( propertyNames )<\/code> where the <strong>propertyNames<\/strong> is an <strong>array<\/strong> of one or more CSS properties.<\/p>\n<p>The method will get the value of a computed style property for the first element in the set of matched elements or set one or more CSS properties for every matched element.<\/p>\n<h3>2.2 A Basic Application<\/h3>\n<p>Let us apply the method on a simple case. First, add a text element on HTML, say, for example, a <code>h3<\/code>:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION  --&gt;\r\n&lt;h3&gt;I am a basic example&lt;\/h3&gt;\r\n<\/pre>\n<p>In the JS section, let&#8217;s change the color of the text to blue:<\/p>\n<pre class=\"brush:js\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n    $('h3').css({color: '#2980b9'});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result would be pretty straight:<br \/>\n<a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css1.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css1.jpg\" alt=\"css1\" width=\"820\" height=\"113\" class=\"aligncenter size-full wp-image-7774\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css1.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css1-300x41.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><\/p>\n<p>Additionally, we can as many properties as we like to that element separated by a comma, for example:<\/p>\n<pre class=\"brush:js\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$('h3').css({\r\n    color: '#fff',\r\n    background: '#1abc9c',\r\n    padding: '1em',\r\n    width: '20%'\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result in this case is:<br \/>\n<a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css2.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css2.jpg\" alt=\"css2\" width=\"820\" height=\"113\" class=\"aligncenter size-full wp-image-7777\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css2.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css2-300x41.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><\/p>\n<p>Simple as that, follow this rule when trying to change styles with jQuery: <code>$('jQuery selector').css({\"css property name\":\"css property value\"});<\/code><\/p>\n<h2>3. Styling Cases<\/h2>\n<h3>3.1 Changing Style on Events<\/h3>\n<p>Just like you can change styling as soon as the HTML is ready, you can also choose to do this on specific event listeners. Let&#8217;s modify the example above to apply styling on <code>mouseover<\/code>:<\/p>\n<pre class=\"brush:js\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$('h3').mouseover(function() {\r\n    $(this).css({\r\n    color: '#fff',\r\n    background: '#1abc9c',\r\n    padding: '1em',\r\n    width: '20%'\r\n    });\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css3.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css3.gif\" alt=\"css3\" width=\"820\" height=\"148\" class=\"aligncenter size-full wp-image-7780\" \/><\/a><\/p>\n<h3>3.2 Extend Existing Styles Values<\/h3>\n<p>You may wish to just extend a style based upon it\u2019s current value. For example, if an element\u2019s padding-left was 10px then the following code would result in a total padding-left of 25px.<\/p>\n<pre class=\"brush:js\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$('selector').css( \"padding-left\", \"+=15\" );\r\n&lt;\/script&gt;\r\n<\/pre>\n<h3>3.3 <strong>.css()<\/strong> Function Property<\/h3>\n<p>As most of you may already know, as of jQuery 1.4, .css() allows us to pass a function as the property value. This is handy for returning current CSS values to determine changes.<\/p>\n<pre class=\"brush:js\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$('div.example').css('width', function(index) {\r\n  return index * 50;\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<h3>3.4 Alternative Approach to <strong>.css()<\/strong> Method<\/h3>\n<p>Well, up until now, we&#8217;ve only been focused to the .css() method. However, there is also another useful way to change styles dynamically, and this includes the <code>.addClass<\/code> and <code>removeClass<\/code> methods of jQuery. To see how this works, first create two non-existing classes in CSS like so:<\/p>\n<pre class=\"brush:css\">\r\n.basic {\r\n    font-size: 1.2em;\r\n    font-weight: 300;\r\n    color: #c0392b;\r\n    border: 0.1em solid #ccc;\r\n    width: 25%;\r\n}\r\n.stylish {\r\n    font-size: 1.5em;\r\n    font-weight: 500;\r\n    color: #fff;\r\n    padding: 1.5em;\r\n    background: #8e44ad;\r\n    width: 25%;\r\n}\r\n<\/pre>\n<p>Now in the HTML section, add a new <code>div<\/code> element with some text inside:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;div&gt;An Alternative Set of Methods&lt;\/div&gt;\r\n<\/pre>\n<p>The idea is to add a class and then remove it or do it in the same time.<\/p>\n<p><strong>CASE 1<\/strong> &#8211; Adding a Class<\/p>\n<pre class=\"brush:js\">\r\n$('div').addClass('basic');\r\n<\/pre>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css4.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css4.jpg\" alt=\"css4\" width=\"820\" height=\"149\" class=\"aligncenter size-full wp-image-7784\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css4.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css4-300x55.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><\/p>\n<p><strong>CASE 2<\/strong> &#8211; Removing a Class and Adding Another<\/p>\n<pre class=\"brush:js\">\r\n$('div').removeClass('basic').addClass('stylish');\r\n<\/pre>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css5.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css5.jpg\" alt=\"css5\" width=\"820\" height=\"301\" class=\"aligncenter size-full wp-image-7785\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css5.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/css5-300x110.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><\/p>\n<h2>4. Conclusion<\/h2>\n<p>The .css() method is a convenient way to get a computed style property from the first matched element, especially in light of the different ways browsers access most of those properties (the <code>getComputedStyle()<\/code> method in standards-based browsers versus the currentStyle and runtimeStyle properties in Internet Explorer) and the different terms browsers use for certain properties. The trend of changing styles dynamically is taking over the web more and more and this knowledge is a must for web developers and designers.<\/p>\n<h2>5. Download<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/jQuery-CSS.zip\"><strong>jQuery CSS<\/strong><\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The aim of this example is to show how you can manipulate CSS, add or remove styling from elements in a dynamic manner, made possible by the famous JS library, jQuery. Now jQuery offers reliable ways to select elements and apply methods, which basically means that what we want to do, shall be found inside &hellip;<\/p>\n","protected":false},"author":75,"featured_media":919,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[236],"class_list":["post-7762","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery","tag-css"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>jQuery CSS add\/remove Style Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"The aim of this example is to show how you can manipulate CSS, add or remove styling from elements in a dynamic manner, made possible by the famous JS\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"jQuery CSS add\/remove Style Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"The aim of this example is to show how you can manipulate CSS, add or remove styling from elements in a dynamic manner, made possible by the famous JS\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/fabiocimo\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-21T13:15:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-21T13:52:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Fabio Cimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fabiocimo\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fabio Cimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/\"},\"author\":{\"name\":\"Fabio Cimo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\"},\"headline\":\"jQuery CSS add\/remove Style Example\",\"datePublished\":\"2015-10-21T13:15:21+00:00\",\"dateModified\":\"2017-12-21T13:52:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/\"},\"wordCount\":626,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"keywords\":[\"CSS\"],\"articleSection\":[\"jQuery\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/\",\"name\":\"jQuery CSS add\/remove Style Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"datePublished\":\"2015-10-21T13:15:21+00:00\",\"dateModified\":\"2017-12-21T13:52:12+00:00\",\"description\":\"The aim of this example is to show how you can manipulate CSS, add or remove styling from elements in a dynamic manner, made possible by the famous JS\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"jQuery\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"jQuery CSS add\/remove Style Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\",\"name\":\"Fabio Cimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"caption\":\"Fabio Cimo\"},\"description\":\"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.\",\"sameAs\":[\"https:\/\/www.facebook.com\/fabiocimo\",\"https:\/\/al.linkedin.com\/in\/fabiocimo\",\"https:\/\/x.com\/fabiocimo\",\"https:\/\/www.youtube.com\/fabiocimo1\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"jQuery CSS add\/remove Style Example - Web Code Geeks - 2026","description":"The aim of this example is to show how you can manipulate CSS, add or remove styling from elements in a dynamic manner, made possible by the famous JS","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/","og_locale":"en_US","og_type":"article","og_title":"jQuery CSS add\/remove Style Example - Web Code Geeks - 2026","og_description":"The aim of this example is to show how you can manipulate CSS, add or remove styling from elements in a dynamic manner, made possible by the famous JS","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/fabiocimo","article_published_time":"2015-10-21T13:15:21+00:00","article_modified_time":"2017-12-21T13:52:12+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","type":"image\/jpeg"}],"author":"Fabio Cimo","twitter_card":"summary_large_image","twitter_creator":"@fabiocimo","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Fabio Cimo","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/"},"author":{"name":"Fabio Cimo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22"},"headline":"jQuery CSS add\/remove Style Example","datePublished":"2015-10-21T13:15:21+00:00","dateModified":"2017-12-21T13:52:12+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/"},"wordCount":626,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","keywords":["CSS"],"articleSection":["jQuery"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/","name":"jQuery CSS add\/remove Style Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","datePublished":"2015-10-21T13:15:21+00:00","dateModified":"2017-12-21T13:52:12+00:00","description":"The aim of this example is to show how you can manipulate CSS, add or remove styling from elements in a dynamic manner, made possible by the famous JS","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-css-addremove-style-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"jQuery","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/"},{"@type":"ListItem","position":4,"name":"jQuery CSS add\/remove Style Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22","name":"Fabio Cimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","caption":"Fabio Cimo"},"description":"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.","sameAs":["https:\/\/www.facebook.com\/fabiocimo","https:\/\/al.linkedin.com\/in\/fabiocimo","https:\/\/x.com\/fabiocimo","https:\/\/www.youtube.com\/fabiocimo1"],"url":"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/7762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=7762"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/7762\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/919"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=7762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=7762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=7762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}