<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JQuery addClass &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/jquery-addclass/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 10 Jul 2018 11:49:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>JQuery addClass &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Overwrite CSS Styles Using addClass In JQuery</title>
		<link>https://sibeeshpassion.com/overwrite-css-styles-using-addclass-in-jquery/</link>
					<comments>https://sibeeshpassion.com/overwrite-css-styles-using-addclass-in-jquery/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 21 Oct 2015 00:06:18 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JQuery addClass]]></category>
		<category><![CDATA[jquery functions]]></category>
		<category><![CDATA[Overwrite CSS Styles]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10811</guid>

					<description><![CDATA[In this post we will see how we can overwrite CSS styles using addClass method in jQuery. We have so many options to change the styles of a particular element. We can do it by editing the style sheet manually. But what if you want to do the same dynamically? If you need to change a CSS property dynamically, I suggest you to read it here: CSS Important . In this post we are applying more CSS rules to the same element. I hope you will like this. Here I am using jQuery 2.0.2 version, you can use whichever version [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can overwrite <a href="http://sibeeshpassion.com/category/css/" target="_blank">CSS </a>styles using addClass method in jQuery. We have so many options to change the styles of a particular element. We can do it by editing the style sheet manually. But what if you want to do the same dynamically? If you need to change a CSS property dynamically, I suggest you to read it here: <a href="http://sibeeshpassion.com/apply-css-important-in-jquery-and-css/" target="_blank">CSS Important </a>. In this post we are applying more CSS rules to the same element. I hope you will like this.</p>
<blockquote><p>Here I am using jQuery 2.0.2 version, you can use whichever version you like. </p></blockquote>
<p><strong>Background</strong></p>
<p>Recently I have got a requirement of changing a CSS property of an element which is common for element. So I wanted to change the CSS property only if my condition becomes true. In this situation I used jQuery addClass to do this requirement. Here I will show you how. </p>
<p><strong>Using the code</strong></p>
<p>First thing you need to do is create a page.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;AddClass JQuery Demo &#8211; Sibeesh Passion&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
   AddClass JQuery Demo &#8211; Sibeesh Passion<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>Then you need to include the script needed.</p>
<p>[js]<br />
&lt;script src=&quot;http://sibeeshpassion.com/content/scripts/jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
[/js]</p>
<p>Now you need to write the scripts.</p>
<p>[js]<br />
&lt;script&gt;<br />
        $(document).ready(function () {<br />
            setTimeout(function () {<br />
				$(&#8216;.first&#8217;).addClass(&#8216;second&#8217;);<br />
			}, 5000);<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>We are adding a new CSS style <em>second </em> to a class <em>first </em>. We will add this after five seconds of document ready. So now we need to create the styles right?</p>
<p>[css]<br />
  &lt;style&gt;<br />
        .first {<br />
            width: 100px;<br />
	    height: 100px;<br />
            border: 1px solid #ccc;<br />
            border-radius: 5px;<br />
            padding: 10px;<br />
            margin: 10px;<br />
            box-shadow: 1px 1px 1px #999;<br />
            font-style: oblique;<br />
            text-align: center;<br />
			background:green;<br />
        }<br />
	.second {<br />
            width: 200px;<br />
	    height: 200px;<br />
            border: 1px solid #ccc;<br />
            border-radius: 5px;<br />
            padding: 10px;<br />
            margin: 10px;<br />
            box-shadow: 1px 1px 1px #999;<br />
            background: blue;<br />
            font-style: oblique;<br />
            text-align: center;<br />
        }<br />
    &lt;/style&gt;<br />
[/css]</p>
<p>Now please run your browser, you can see the following output. </p>
<div id="attachment_10812" style="width: 303px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Overwrite_CSS_Styles.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-10812" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Overwrite_CSS_Styles.png" alt="Overwrite CSS Styles Using addClass" width="293" height="181" class="size-full wp-image-10812" /></a><p id="caption-attachment-10812" class="wp-caption-text">Overwrite CSS Styles Using addClass</p></div>
<p>Now after five seconds, the same element will look as follows.</p>
<div id="attachment_10813" style="width: 324px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Overwrite_CSS_Styles1.png"><img decoding="async" aria-describedby="caption-attachment-10813" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Overwrite_CSS_Styles1.png" alt="Overwrite CSS Styles Using addClass" width="314" height="298" class="size-full wp-image-10813" srcset="/wp-content/uploads/2015/10/Overwrite_CSS_Styles1.png 314w, /wp-content/uploads/2015/10/Overwrite_CSS_Styles1-300x285.png 300w" sizes="(max-width: 314px) 100vw, 314px" /></a><p id="caption-attachment-10813" class="wp-caption-text">Overwrite CSS Styles Using addClass</p></div>
<p>If you look at your browser console, you can see both of the styles are applied to the element. </p>
<div id="attachment_10814" style="width: 610px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Overwrite_CSS_Styles2.png"><img decoding="async" aria-describedby="caption-attachment-10814" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Overwrite_CSS_Styles2.png" alt="Overwrite CSS Styles Using addClass" width="600" height="626" class="size-full wp-image-10814" srcset="/wp-content/uploads/2015/10/Overwrite_CSS_Styles2.png 600w, /wp-content/uploads/2015/10/Overwrite_CSS_Styles2-288x300.png 288w, /wp-content/uploads/2015/10/Overwrite_CSS_Styles2-400x417.png 400w, /wp-content/uploads/2015/10/Overwrite_CSS_Styles2-575x600.png 575w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-10814" class="wp-caption-text">Overwrite CSS Styles Using addClass</p></div>
<p>That&#8217;s all, now we can see the complete code here.</p>
<blockquote><p>Here I am using setTimeout as my condition, you can use any condition according to your requirement. </p></blockquote>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;AddClass JQuery Demo &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;http://sibeeshpassion.com/content/scripts/jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        $(document).ready(function () {<br />
            setTimeout(function () {<br />
				$(&#8216;.first&#8217;).addClass(&#8216;second&#8217;);<br />
			}, 5000);<br />
        });<br />
    &lt;/script&gt;<br />
    &lt;style&gt;<br />
        .first {<br />
            width: 100px;<br />
			height: 100px;<br />
            border: 1px solid #ccc;<br />
            border-radius: 5px;<br />
            padding: 10px;<br />
            margin: 10px;<br />
            box-shadow: 1px 1px 1px #999;<br />
            font-style: oblique;<br />
            text-align: center;<br />
			background:green;<br />
        }<br />
		.second {<br />
            width: 200px;<br />
			height: 200px;<br />
            border: 1px solid #ccc;<br />
            border-radius: 5px;<br />
            padding: 10px;<br />
            margin: 10px;<br />
            box-shadow: 1px 1px 1px #999;<br />
            background: blue;<br />
            font-style: oblique;<br />
            text-align: center;<br />
        }<br />
    &lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    AddClass JQuery Demo &#8211; Sibeesh Passion<br />
	&lt;div class=&quot;first&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever wanted to do this requirement? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/overwrite-css-styles-using-addclass-in-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to add a css class to an element in JQuery</title>
		<link>https://sibeeshpassion.com/how-to-add-a-css-class-to-an-element-in-jquery/</link>
					<comments>https://sibeeshpassion.com/how-to-add-a-css-class-to-an-element-in-jquery/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sun, 31 May 2015 13:35:28 +0000</pubDate>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Add CSS Class]]></category>
		<category><![CDATA[Apply CSS class to an Element]]></category>
		<category><![CDATA[JQuery addClass]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=3101</guid>

					<description><![CDATA[How to add a css class to an element in JQuery [js] $(&#34;#myElement&#34;).addClass(&#8216;myClass&#8217;); [/js]]]></description>
										<content:encoded><![CDATA[<p>How to add a css class to an element in JQuery<br />
[js]<br />
$(&quot;#myElement&quot;).addClass(&#8216;myClass&#8217;);<br />
[/js]</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/how-to-add-a-css-class-to-an-element-in-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
