<?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>.remove() &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/remove/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 11 Jul 2018 16:27:17 +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>.remove() &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Remove a DOM element using JQuery</title>
		<link>https://sibeeshpassion.com/remove-a-dom-element-using-jquery/</link>
					<comments>https://sibeeshpassion.com/remove-a-dom-element-using-jquery/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 01 Jul 2015 10:22:00 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[.remove()]]></category>
		<category><![CDATA[delete UI]]></category>
		<category><![CDATA[jquery events]]></category>
		<category><![CDATA[jquery functions]]></category>
		<category><![CDATA[remove DOM]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=5981</guid>

					<description><![CDATA[Introduction Hi All, How are you today? In this article we will see how we can remove a DOM element using JQuery. I hope you will like it. Background I know we all are working in the client side technologies, especially in JQuery. Sometimes we may need to write more client side codes rather than server side codes. In that case, you may need to remove some DOM elements pragmatically. Here I am going to give you a demo of how we can do this requirement. Using the code To start with, as you all know we need to load [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Hi All, How are you today? In this article we will see how we can remove a DOM element using JQuery. I hope you will like it.</p>
<p><strong>Background</strong></p>
<p>I know we all are working in the client side technologies, especially in JQuery. Sometimes we may need to write more client side codes rather than server side codes. In that case, you may need to remove some DOM elements pragmatically. Here I am going to give you a demo of how we can do this requirement.</p>
<p><strong>Using the code</strong></p>
<p>To start with, as you all know we need to load the JQuery reference.</p>
<p>[js]<br />
&lt;script src=&quot;https://code.jquery.com/jquery-2.1.4.min.js&quot;&gt;&lt;/script&gt;<br />
[/js]</p>
<p>Once you load the reference you are ready to go.</p>
<p>Since this is a demo, we will explain with some steps. Sounds good?. So we will do the following tasks.</p>
<li>Add the elements to the DOM</li>
<li>Delete the DOM elements using <em>.remove()</em>, <em>.get()</em> functions</li>
<p>Shall we start then?</p>
<p><strong>Add the elements to the DOM</strong></p>
<p>We need to set our UI first right?</p>
<p>[html]<br />
&lt;body id=&quot;body&quot;&gt;<br />
    Remove a DOM element from the UI using JQuery- Sibeesh Passion<br />
    &lt;br/&gt;<br />
    &lt;br/&gt;<br />
    &lt;p id=&quot;addMe&quot;&gt;Generate 10 Elements&lt;/p&gt;<br />
&lt;/body&gt;<br />
[/html]</p>
<p><strong>Add CSS</strong><br />
[css]<br />
&lt;style&gt;<br />
        p {<br />
            color: red;<br />
            width: 170px;<br />
            cursor: pointer;<br />
            border: 1px solid #ccc;<br />
            text-align: center;<br />
        }<br />
        #deleteMe {<br />
            color: white;<br />
            width: 170px;<br />
            cursor: pointer;<br />
            border: 1px solid #ccc;<br />
            text-align: center;<br />
            background-color: blue;<br />
        }<br />
    &lt;/style&gt;<br />
[/css]</p>
<p>So we have set our UI, and now if you run your page you can see output as follows.</p>
<p><img decoding="async" src="http://www.sibeeshpassion.com/content/images/rmdm1.png" alt="www.sibeeshpassion.com" /></p>
<p>Now we will add the needful scripts.</p>
<p>[js]<br />
 &lt;script&gt;<br />
        $(document).ready(function() {<br />
            $(&quot;#addMe&quot;).click(function() {<br />
                var html = &#8216;&lt;table&gt;&#8217;;<br />
                for (var i = 1; i &lt;= 10; i++) {<br />
                    html += &quot;&lt;tr&gt;&lt;p&gt;My Elements&lt;/p&gt;&lt;/tr&gt;&quot;;<br />
                }<br />
                html += &#8216;&lt;/table&gt;&#8217;;<br />
                $(&#8216;#body&#8217;).append(html).append(&#8216;&lt;div id=&quot;deleteMe&quot;&gt;Delete 5 Elements&lt;/div&gt;&#8217;);<br />
                $(&quot;#addMe&quot;).hide();<br />
            });<br />
            $(document).on(&#8216;click&#8217;, &#8216;#deleteMe&#8217;, function() {<br />
                for (var i = 1; i &lt;= 5; i++) {<br />
                    $(&#8216;#body&#8217;).find(&#8216;p&#8217;).get(i).remove();<br />
                }<br />
                $(&quot;#addMe&quot;).hide();<br />
                $(&quot;#deleteMe&quot;).hide();<br />
            });</p>
<p>        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>As you can see we are adding elements to the DOM with a loop. Once you run the page you can see the output as follows.</p>
<p><img decoding="async" src="http://www.sibeeshpassion.com/content/images/rmdm2.png" alt="www.sibeeshpassion.com" /></p>
<p>And once you click on &#8220;Delete 5 Elements&#8221; button, 5 DOM elements will be deleted.</p>
<p><img decoding="async" src="http://www.sibeeshpassion.com/content/images/rmdm3.png" alt="www.sibeeshpassion.com" /></p>
<p>The following code block describes how we can use <em>.remove()</em> function.</p>
<p>[js]<br />
 $(&#8216;#body&#8217;).find(&#8216;p&#8217;).get(i).remove();<br />
[/js]</p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;html&gt;</p>
<p>&lt;head&gt;<br />
    &lt;title&gt;emove a DOM element from the UI usign JQuery- Sibeesh Passion&lt;/title&gt;<br />
    &lt;style&gt;<br />
        p {<br />
            color: red;<br />
            width: 170px;<br />
            cursor: pointer;<br />
            border: 1px solid #ccc;<br />
            text-align: center;<br />
        }<br />
        #deleteMe {<br />
            color: white;<br />
            width: 170px;<br />
            cursor: pointer;<br />
            border: 1px solid #ccc;<br />
            text-align: center;<br />
            background-color: blue;<br />
        }<br />
    &lt;/style&gt;<br />
    &lt;script src=&quot;https://code.jquery.com/jquery-2.1.4.min.js&quot;&gt;&lt;/script&gt;<br />
&lt;/head&gt;</p>
<p>&lt;body id=&quot;body&quot;&gt;<br />
    Remove a DOM element from the UI using JQuery- Sibeesh Passion<br />
    &lt;br/&gt;<br />
    &lt;br/&gt;<br />
    &lt;p id=&quot;addMe&quot;&gt;Generate 10 Elements&lt;/p&gt;<br />
    &lt;script&gt;<br />
        $(document).ready(function() {<br />
            $(&quot;#addMe&quot;).click(function() {<br />
                var html = &#8216;&lt;table&gt;&#8217;;<br />
                for (var i = 1; i &lt;= 10; i++) {<br />
                    html += &quot;&lt;tr&gt;&lt;p&gt;My Elements&lt;/p&gt;&lt;/tr&gt;&quot;;<br />
                }<br />
                html += &#8216;&lt;/table&gt;&#8217;;<br />
                $(&#8216;#body&#8217;).append(html).append(&#8216;&lt;div id=&quot;deleteMe&quot;&gt;Delete 5 Elements&lt;/div&gt;&#8217;);<br />
                $(&quot;#addMe&quot;).hide();<br />
            });<br />
            $(document).on(&#8216;click&#8217;, &#8216;#deleteMe&#8217;, function() {<br />
                for (var i = 1; i &lt;= 5; i++) {<br />
                    $(&#8216;#body&#8217;).find(&#8216;p&#8217;).get(i).remove();<br />
                }<br />
                $(&quot;#addMe&quot;).hide();<br />
                $(&quot;#deleteMe&quot;).hide();<br />
            });</p>
<p>        });<br />
    &lt;/script&gt;<br />
&lt;/body&gt;</p>
<p>&lt;/html&gt;<br />
[/html]</p>
<p><strong>Conclusion</strong></p>
<p>I hope you will like this article. Please share me your valuable thoughts and comments. Your feedback is always welcomed.</p>
<p>Thanks in advance. Happy coding!</p>
<p>Kindest Regards<br />
<a href="https://plus.google.com/+sibeeshkv" target="_blank">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/remove-a-dom-element-using-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
