<?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 Archives - The Code Developer</title>
	<atom:link href="https://www.thecodedeveloper.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.thecodedeveloper.com/category/jquery/</link>
	<description>The Code Developer is a Programming Blog.</description>
	<lastBuildDate>Wed, 30 Jan 2019 21:22:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>How to Get Selected Checkboxes Value Using jQuery</title>
		<link>https://www.thecodedeveloper.com/get-selected-checkboxes-value-using-jquery/</link>
					<comments>https://www.thecodedeveloper.com/get-selected-checkboxes-value-using-jquery/#respond</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Mon, 06 Aug 2018 15:41:50 +0000</pubDate>
				<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=3035</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="903" height="499" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/08/get-selected-checkboxes-value-using-jQuery.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Get Selected Checkboxes Value Using JQuery" decoding="async" fetchpriority="high" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/08/get-selected-checkboxes-value-using-jQuery.png 903w, https://www.thecodedeveloper.com/wp-content/uploads/2018/08/get-selected-checkboxes-value-using-jQuery-442x244.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/08/get-selected-checkboxes-value-using-jQuery-768x424.png 768w" sizes="(max-width: 903px) 100vw, 903px" /></div>
<p>In this tutorial we will explain how to get selected Checkboxes value Using jQuery. First user need to select one or more checkbox field in a form then we will get all value of checkbox in an array. The jQuery :checked selector can be used with the each() method to retrieve the values of all [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/get-selected-checkboxes-value-using-jquery/">How to Get Selected Checkboxes Value Using jQuery</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="903" height="499" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/08/get-selected-checkboxes-value-using-jQuery.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Get Selected Checkboxes Value Using JQuery" decoding="async" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/08/get-selected-checkboxes-value-using-jQuery.png 903w, https://www.thecodedeveloper.com/wp-content/uploads/2018/08/get-selected-checkboxes-value-using-jQuery-442x244.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/08/get-selected-checkboxes-value-using-jQuery-768x424.png 768w" sizes="(max-width: 903px) 100vw, 903px" /></div><p>In this tutorial we will explain how to <strong>get selected Checkboxes value Using jQuery</strong>. First user need to select one or more checkbox field in a form then we will get all value of checkbox in an array.</p>
<p>The <strong>jQuery :checked</strong> selector can be used with the each() method to retrieve the values of all checkboxes selected in group. <strong>jQuery.each()</strong> method used here simply iterates over all the checkboxes that are checked.</p>
<h2><a href="https://www.thecodedeveloper.com/demo/get-selected-checkboxes-value-using-jquery/" rel="noopener" target="_blank">Live Demo</a></h2>
<h2>First include the jQuery library file before the closing <code class="highlighter-code">&lt;/head&gt;</code> tag. </h2>
<pre class="brush: php; title: ; notranslate">
 &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js&quot;&gt;&lt;/script&gt;
</pre>
<h2>Creating HTML Form with Checkboxes</h2>
<p>This HTML shows a form containing a list of colors with checkbox field.</p>
<pre class="brush: php; title: ; notranslate">
&lt;form method=&quot;POST&quot;&gt;
    &lt;h3&gt;Select your favorite colors:&lt;/h3&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;red&quot; name=&quot;color&quot;&gt; Red&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;orange&quot; name=&quot;color&quot;&gt; Orange&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;yellow&quot; name=&quot;color&quot;&gt; Yellow&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;green&quot; name=&quot;color&quot;&gt; Green&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;blue&quot; name=&quot;color&quot;&gt; Blue&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;purple&quot; name=&quot;color&quot;&gt; Purple&lt;/label&gt;&lt;/div&gt;
    &lt;br&gt;
    &lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot;&gt;Get Values&lt;/button&gt;
&lt;/form&gt;
</pre>
<h2>Get Selected Checkboxes Value Using jQuery</h2>
<p>Then we write jQuery script to get selected checkbox value in an array using jQuery each(). Using this jQuery function it runs a loop to get the checked value and put it into an array.</p>
<pre class="brush: php; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function() {
        $(&quot;.btn&quot;).click(function() {
            var colors = &#x5B;];
            $.each($(&quot;input&#x5B;name='color']:checked&quot;), function() {
                colors.push($(this).val());
            });
            alert(&quot;My favourite colors are: &quot; + colors.join(&quot;, &quot;));
        });
    });
&lt;/script&gt;
</pre>
<h2>Index.html</h2>
<p>In this file we contains complete code with jQuery library, jQuery script and HTML form.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot;&gt;
&lt;title&gt;Get Selected Checkboxes Value Using jQuery&lt;/title&gt;
&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function() {
        $(&quot;.btn&quot;).click(function() {
            var colors = &#x5B;];
            $.each($(&quot;input&#x5B;name='color']:checked&quot;), function() {
                colors.push($(this).val());
            });
            alert(&quot;My favourite colors are: &quot; + colors.join(&quot;, &quot;));
        });
    });
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form method=&quot;POST&quot;&gt;
    &lt;h3&gt;Select your favorite colors:&lt;/h3&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;red&quot; name=&quot;color&quot;&gt; Red&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;orange&quot; name=&quot;color&quot;&gt; Orange&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;yellow&quot; name=&quot;color&quot;&gt; Yellow&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;green&quot; name=&quot;color&quot;&gt; Green&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;blue&quot; name=&quot;color&quot;&gt; Blue&lt;/label&gt;&lt;/div&gt;
    &lt;div class=&quot;checkbox&quot;&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot; value=&quot;purple&quot; name=&quot;color&quot;&gt; Purple&lt;/label&gt;&lt;/div&gt;
    &lt;br&gt;
    &lt;button type=&quot;button&quot; class=&quot;btn&quot;&gt;Get Values&lt;/button&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The post <a href="https://www.thecodedeveloper.com/get-selected-checkboxes-value-using-jquery/">How to Get Selected Checkboxes Value Using jQuery</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/get-selected-checkboxes-value-using-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Disable Past date time in DateTimePicker jQuery plugin</title>
		<link>https://www.thecodedeveloper.com/disable-past-date-time/</link>
					<comments>https://www.thecodedeveloper.com/disable-past-date-time/#comments</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Sun, 08 Apr 2018 18:53:48 +0000</pubDate>
				<category><![CDATA[DateTimePicker]]></category>
		<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=2703</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="910" height="449" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="disable past date time" decoding="async" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time.png 910w, https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time-442x218.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time-768x379.png 768w" sizes="(max-width: 910px) 100vw, 910px" /></div>
<p>Nowadays i was working a project and in this project one of the task i am using DateTimePicker jQuery plugin to select date time. According the task requirement I don&#8217;t want to allow user to select any past date time, only user can select current or future date time. So Today in this article i [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/disable-past-date-time/">Disable Past date time in DateTimePicker jQuery plugin</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="910" height="449" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="disable past date time" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time.png 910w, https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time-442x218.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time-768x379.png 768w" sizes="auto, (max-width: 910px) 100vw, 910px" /></div><p>Nowadays i was working a project and in this project one of the task i am using <a href="https://github.com/xdan/datetimepicker" target="_blank" rel="noopener">DateTimePicker</a> jQuery plugin to select date time. According the task requirement I don&#8217;t want to allow user to select any past date time, only user can select current or future date time. So Today in this article i will explain how to Disable Past date time with DateTimePicker jQuery plugin.</p>
<p><strong>Read Also: </strong> <a href="https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/">How to Install DateTimePicker jQuery plugin</a></p>
<h2>Disable Past date time in DateTimePicker jQuery plugin</h2>
<p>First we try to disable Past Date with <strong>minDate: 0</strong> option:</p>
<pre class="brush: php; title: ; notranslate">
//minDate option Example
$('#datetimepicker5').datetimepicker({
	minDate:0, // disable past date
});
</pre>
<p><strong>Output: </strong></p>
<p><input id="datetimepicker5" type="text" /></p>
<p>Now i try to disable Past Date and Time with <strong>minDate: 0</strong> and <strong>minTime: 0</strong> option:</p>
<pre class="brush: php; title: ; notranslate">
//minDate and minTime option Example
$('#datetimepicker6').datetimepicker({
	minDate: 0,  // disable past date
	minTime: 0, // disable past time
});
</pre>
<p><strong>Output: </strong></p>
<p><input id="datetimepicker6" type="text" /></p>
<p><strong>In the above output i have found two issue:</strong></p>
<p><strong>Issue 1:</strong> If current time is 2:00 AM, then user can&#8217;t select current time to 2:00 AM.</p>
<p><strong>Issue 2:</strong> If user select future date then some time disable, e.g if current time is 3:00 AM, user can&#8217;t select time to 3:00 AM, 2:00 AM, 1:00 AM. But i want if user select future date then every time should be visible to select.</p>
<p>so here <strong>minTime: 0</strong> option did&#8217;t work for me.</p>
<p>I wrote below code to fix above issues, in this code if user select today date then pass current time with <strong>minTime</strong> option and for future date all time will be visible to select.</p>
<pre class="brush: jscript; title: ; notranslate">
var checkPastTime = function(inputDateTime) {
    if (typeof(inputDateTime) != &quot;undefined&quot; &amp;&amp; inputDateTime !== null) {
        var current = new Date();

        //check past year and month
        if (inputDateTime.getFullYear() &lt; current.getFullYear()) {
            $('#datetimepicker7').datetimepicker('reset');
            alert(&quot;Sorry! Past date time not allow.&quot;);
        } else if ((inputDateTime.getFullYear() == current.getFullYear()) &amp;&amp; (inputDateTime.getMonth() &lt; current.getMonth())) {
            $('#datetimepicker7').datetimepicker('reset');
            alert(&quot;Sorry! Past date time not allow.&quot;);
        }

        // 'this' is jquery object datetimepicker
        // check input date equal to todate date
        if (inputDateTime.getDate() == current.getDate()) {
            if (inputDateTime.getHours() &lt; current.getHours()) {
                $('#datetimepicker7').datetimepicker('reset');
            }
            this.setOptions({
                minTime: current.getHours() + ':00' //here pass current time hour
            });
        } else {
            this.setOptions({
                minTime: false
            });
        }
    }
};

var currentYear = new Date();
$('#datetimepicker7').datetimepicker({
	format:'Y-m-d H:i',
	minDate : 0,
	yearStart : currentYear.getFullYear(), // Start value for current Year selector
	onChangeDateTime:checkPastTime,
	onShow:checkPastTime
});

</pre>
<p><input id="datetimepicker7" type="text" /></p>
<p>I can’t express how happy I am to see my code is working fine.</p>
<p>The post <a href="https://www.thecodedeveloper.com/disable-past-date-time/">Disable Past date time in DateTimePicker jQuery plugin</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/disable-past-date-time/feed/</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
		<item>
		<title>Add a DateTimePicker jQuery plugin to Input Field</title>
		<link>https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/</link>
					<comments>https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/#comments</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Wed, 04 Apr 2018 05:53:56 +0000</pubDate>
				<category><![CDATA[DateTimePicker]]></category>
		<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=2713</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="910" height="449" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="DateTimePicker jQuery plugin" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin.png 910w, https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin-442x218.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin-768x379.png 768w" sizes="auto, (max-width: 910px) 100vw, 910px" /></div>
<p>This Article shows the simplest way to add date time picker functionality to your websites to provide better end user experience. Here we are using DateTimePicker jQuery plugin to add date-time picker to input field, this article will help you lot for that. This plugin is very simple and easy to implement and provides various [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/">Add a DateTimePicker jQuery plugin to Input Field</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="910" height="449" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="DateTimePicker jQuery plugin" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin.png 910w, https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin-442x218.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin-768x379.png 768w" sizes="auto, (max-width: 910px) 100vw, 910px" /></div><p>This Article shows the simplest way to add date time picker functionality to your websites to provide better end user experience. Here we are using <a href="https://github.com/xdan/datetimepicker" target="_blank" rel="noopener">DateTimePicker</a> jQuery plugin to add date-time picker to input field, this article will help you lot for that. This plugin is very simple and easy to implement and provides various options to customize your Date Time Picker as per your project requirement.</p>
<h2><a href="https://www.thecodedeveloper.com/demo/add-datetimepicker-jquery-plugin/" rel="noopener" target="_blank">Live Demo</a></h2>
<h2>Setting up DateTimePicker jQuery plugin</h2>
<p>First include the jQuery library file before the closing <code class="highlighter-code">&lt;/head&gt;</code> tag.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!-- this file should add inside the &lt;head&gt;&lt;/head&gt; tag --&gt;
&lt;script src=&quot;js/jquery.min.js&quot;&gt;&lt;/script&gt;
</pre>
<p>Now include the js and css files of DateTime Picker jQuery plugin. those files should be add after the <code class="highlighter-code">&lt;/body&gt;</code> tag.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!-- those files should be add after the &lt;/body&gt; tag --&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/jquery.datetimepicker.min.css&quot;/&gt;
&lt;script src=&quot;js/jquery.datetimepicker.js&quot;&gt;&lt;/script&gt;
</pre>
<h4>HTML Code</h4>
<pre class="brush: php; title: ; notranslate">
&lt;input id=&quot;datetimepicker&quot; type=&quot;text&quot; &gt;
</pre>
<h4>JavaScript Code with DatePicker Example</h4>
<pre class="brush: php; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function() {
        $('#datetimepicker').datetimepicker();
    });
&lt;/script&gt;
</pre>
<p><strong>Output:</strong></p>
<p><input type="text" id="datetimepicker"/></p>
<h4>TimePicker Example</h4>
<pre class="brush: php; title: ; notranslate">
//TimePicke Example
$('#datetimepicker1').datetimepicker();
</pre>
<p><strong>Output:</strong></p>
<p><input type="text" id="datetimepicker1"/></p>
<h4>Inline DateTimePicker Example</h4>
<pre class="brush: php; title: ; notranslate">
//Inline DateTimePicker Example
$('#datetimepicker2').datetimepicker({
    format:'Y-m-d H:i',
    inline:true
});
</pre>
<p><strong>Output:</strong></p>
<p><input type="text" id="datetimepicker2"/></p>
<h4>minDate and maxDate Example</h4>
<pre class="brush: php; title: ; notranslate">
//minDate and maxDate Example
$('#datetimepicker3').datetimepicker({
     format:'Y-m-d',
     timepicker:false,
     minDate:'-1970/01/02', //yesterday is minimum date
     maxDate:'+1970/01/02' //tomorrow is maximum date
});
</pre>
<p><strong>Output:</strong></p>
<p><input type="text" id="datetimepicker3"/></p>
<h4>allow particular Times options with TimePicker Example</h4>
<pre class="brush: php; title: ; notranslate">
//allow particular Times options with TimePicker Example
$('#datetimepicker4').datetimepicker({
	datepicker:false,
	allowTimes:&#x5B;
	  '11:00', '13:00', '15:00', 
	  '16:00', '18:00', '19:00', '20:00'
	]
});
</pre>
<p><input type="text" id="datetimepicker4"/></p>
<h2><a href="https://www.thecodedeveloper.com/download/add-datetimepicker-jquery-plugin.zip" rel="noopener" >Download Code File</a></h2>
<p>The post <a href="https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/">Add a DateTimePicker jQuery plugin to Input Field</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
		<item>
		<title>Move Ball using JQuery Animation</title>
		<link>https://www.thecodedeveloper.com/move-ball-using-jquery-animation/</link>
					<comments>https://www.thecodedeveloper.com/move-ball-using-jquery-animation/#respond</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Sat, 04 Nov 2017 18:38:06 +0000</pubDate>
				<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=1936</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="899" height="429" src="https://www.thecodedeveloper.com/wp-content/uploads/2017/11/move-a-ball.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="move Ball" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2017/11/move-a-ball.png 899w, https://www.thecodedeveloper.com/wp-content/uploads/2017/11/move-a-ball-442x211.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2017/11/move-a-ball-768x366.png 768w" sizes="auto, (max-width: 899px) 100vw, 899px" /></div>
<p>This tutorial we will move ball in left to right and right to left in both direction using jQuery Animation. We use jquery animation’s callback function. jQuery animate() function is used to perform a custom animation of a set of CSS properties. This method allows you to create custom animation only on numeric properties. For [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/move-ball-using-jquery-animation/">Move Ball using JQuery Animation</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="899" height="429" src="https://www.thecodedeveloper.com/wp-content/uploads/2017/11/move-a-ball.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="move Ball" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2017/11/move-a-ball.png 899w, https://www.thecodedeveloper.com/wp-content/uploads/2017/11/move-a-ball-442x211.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2017/11/move-a-ball-768x366.png 768w" sizes="auto, (max-width: 899px) 100vw, 899px" /></div><p>This tutorial we will move ball in left to right and right to left in both direction using jQuery Animation. We use jquery animation’s callback function.</p>
<p><strong><a href="http://api.jquery.com/animate/" rel="noopener" target="_blank">jQuery animate()</a></strong> function is used to perform a custom animation of a set of CSS properties. This method allows you to create custom animation only on numeric properties. For example, the properties with numeric values such as width, left, height, opacity can be used with animate() method, but the property like background-color cannot be animated since it has a string value.</p>
<h2><a href="https://www.thecodedeveloper.com/demo/move-ball-using-jquery-animation/" rel="noopener" target="_blank">Move Ball Using JQuery Animation Demo</a></h2>
<p><strong>CSS Code</strong></p>
<pre class="brush: css; title: ; notranslate">
 #ballContainer
{
	float: left;
	position: relative;
}
</pre>
<p><strong>HTML Code</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;div id=&quot;ballContainer&quot;&gt;
&lt;img src=&quot;images/ball.png&quot; width=&quot;200px&quot; alt=&quot;image&quot; /&gt;
&lt;/div&gt;
</pre>
<p><strong>jQuery Code</strong></p>
<p>In moveBall() method first we move the div #ballContainer to right, do it by changing the value of property left to 900px inside the animate method, once animation is done call <strong>complete: Function()</strong>, inside this function move the div #ballContainer to left, do it by changing the value of property left to 10px inside the animate method. After complete second animation call <strong>complete: Function()</strong> then we call moveBall() method to continue move ball process in both direction.</p>
<pre class="brush: php; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;

    $(function() {
        moveBall();
    });

    function moveBall() {
        $(&quot;#ballContainer:first&quot;).animate({
            left: 900
        }, {
            duration: 3000,
            complete: function() {
                $(&quot;#ballContainer:first&quot;).animate({
                    left: 10
                }, {
                    duration: 3000,
                    complete: function() {
                        moveBall();
                    }
                });
            }
        });
    }

&lt;/script&gt;
</pre>
<p><strong>Index.html</strong><br />
In this file we contains complete code with HTML, CSS and JQuery.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
    &lt;title&gt;Move Ball using JQuery Animation&lt;/title&gt;
    &lt;!-- Latest compiled and minified CSS --&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css&quot;&gt;
    &lt;!-- jQuery (necessary for Bootstrap's JavaScript plugins) --&gt;
    &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js&quot;&gt;&lt;/script&gt;

    &lt;style type=&quot;text/css&quot;&gt;
        #ballContainer {
            float: left;
            position: relative;
        }

        .top-buffer {
            margin-top: 50px;
        }
    &lt;/style&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;
        $(function() {
            moveBall();
        });

        function moveBall() {
            $(&quot;#ballContainer:first&quot;).animate({
                left: 900
            }, {
                duration: 3000,
                complete: function() {
                    $(&quot;#ballContainer:first&quot;).animate({
                        left: 10
                    }, {
                        duration: 3000,
                        complete: function() {
                            moveBall();
                        }
                    });
                }
            });
        }
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div class=&quot;container&quot;&gt;
        &lt;h2 class=&quot;text-center p-3 mb-2 bg-primary text-white&quot;&gt;Demo: Move a ball using Jquery&lt;/h2&gt;
        &lt;div class=&quot;row&quot;&gt;
            &lt;div class=&quot;col-sm-12 top-buffer&quot;&gt;
                &lt;div id=&quot;ballContainer&quot;&gt;
                    &lt;img src=&quot;images/ball.png&quot; width=&quot;200px&quot; alt=&quot;image&quot; /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;!-- Latest compiled and minified JavaScript --&gt;
    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2><a href="https://www.thecodedeveloper.com/demo/move-ball-using-jquery-animation/" rel="noopener" target="_blank">Live Demo</a></h2>
<p>The post <a href="https://www.thecodedeveloper.com/move-ball-using-jquery-animation/">Move Ball using JQuery Animation</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/move-ball-using-jquery-animation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
