<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Effect Delay Trick</title>
	<atom:link href="http://www.learningjquery.com/2007/01/effect-delay-trick/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learningjquery.com/2007/01/effect-delay-trick</link>
	<description>Tips, techniques, and tutorials for the jQuery JavaScript library</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:50:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Karl Swedberg</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-83473</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Mon, 14 Feb 2011 13:13:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-83473</guid>
		<description>Hey Nick,
No problem. I hope my reply wasn&#039;t worded too strongly. Your idea was on the right track, and it&#039;s always a good idea to consider how we can simplify things, but it I don&#039;t think it quite applied to this situation. Keep up the good work!</description>
		<content:encoded><![CDATA[<p>Hey Nick,<br />
No problem. I hope my reply wasn&#8217;t worded too strongly. Your idea was on the right track, and it&#8217;s always a good idea to consider how we can simplify things, but it I don&#8217;t think it quite applied to this situation. Keep up the good work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Kougioulis</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-83467</link>
		<dc:creator>Nick Kougioulis</dc:creator>
		<pubDate>Sat, 12 Feb 2011 19:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-83467</guid>
		<description>Thanks for your answer Karl. :)
Will keep these things in mind :)

Btw i added the delay function and achieved a closer result.
&lt;pre&gt;&lt;code&gt;$(document).ready(function(){
$(&quot;#show-alert&quot;).click(function(){
$(&quot;#quick-alert&quot;).fadeIn(30).delay(3000)fadeOut(10);
});
});&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for your answer Karl. :)<br />
Will keep these things in mind :)</p>
<p>Btw i added the delay function and achieved a closer result.</p>
<pre><code>$(document).ready(function(){
$("#show-alert").click(function(){
$("#quick-alert").fadeIn(30).delay(3000)fadeOut(10);
});
});</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Swedberg</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-83466</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Sat, 12 Feb 2011 15:47:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-83466</guid>
		<description>Hi Nick, 

I&#039;m not really seeing how your solution offers any improvement, and it certainly doesn&#039;t have the same result unless you assume that the message is in the HTML to begin with. But to answer your question, the additional jQuery that I propose above has two parts:
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Insertion/removal of the element&lt;/strong&gt;. Often this kind of content doesn&#039;t really belong in the HTML, so inserting it dynamically and then removing it after the message is displayed for a while seems (to me at least) like a reasonable thing to do. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The delay&lt;/strong&gt;. I much prefer having a message remain fully visible for a time over having it fade out as soon as it has finished fading in.  Chaining a &lt;code&gt;.delay()&lt;/code&gt; method, or even using the &lt;code&gt;.animate()&lt;/code&gt; trick, is trivial in terms of both the extra code and the extra time it takes to write it. &lt;/li&gt;
&lt;/ol&gt;
So, let&#039;s say for the sake of argument that we do already have the message in the HTML. The script I initially proposed would look like this:
&lt;pre&gt;&lt;code&gt;$(document).ready(function() {
  $(&#039;#show-alert&#039;).click(function() {
    $(&#039;div.quick-alert&#039;)
    .fadeIn(&#039;slow&#039;)
    &lt;strong&gt;.animate({opacity: 1.0}, 3000)&lt;/strong&gt;
    .fadeOut(&#039;slow&#039;);
  });
});
&lt;/code&gt;&lt;/pre&gt;
Or, as of jQuery 1.4:
&lt;pre&gt;&lt;code&gt;$(document).ready(function() {
  $(&#039;#show-alert&#039;).click(function() {
    $(&#039;div.quick-alert&#039;)
    .fadeIn(&#039;slow&#039;)
    &lt;strong&gt;.delay(3000)&lt;/strong&gt;
    .fadeOut(&#039;slow&#039;);
  });
});
&lt;/code&gt;&lt;/pre&gt;
The only extra code is in bold &#8212; which makes your supermarket analogy seem like a stretch at best.</description>
		<content:encoded><![CDATA[<p>Hi Nick, </p>
<p>I&#8217;m not really seeing how your solution offers any improvement, and it certainly doesn&#8217;t have the same result unless you assume that the message is in the HTML to begin with. But to answer your question, the additional jQuery that I propose above has two parts:</p>
<ol>
<li><strong>Insertion/removal of the element</strong>. Often this kind of content doesn&#8217;t really belong in the HTML, so inserting it dynamically and then removing it after the message is displayed for a while seems (to me at least) like a reasonable thing to do. </li>
<li><strong>The delay</strong>. I much prefer having a message remain fully visible for a time over having it fade out as soon as it has finished fading in.  Chaining a <code>.delay()</code> method, or even using the <code>.animate()</code> trick, is trivial in terms of both the extra code and the extra time it takes to write it. </li>
</ol>
<p>So, let&#8217;s say for the sake of argument that we do already have the message in the HTML. The script I initially proposed would look like this:</p>
<pre><code>$(document).ready(function() {
  $('#show-alert').click(function() {
    $('div.quick-alert')
    .fadeIn('slow')
    <strong>.animate({opacity: 1.0}, 3000)</strong>
    .fadeOut('slow');
  });
});
</code></pre>
<p>Or, as of jQuery 1.4:</p>
<pre><code>$(document).ready(function() {
  $('#show-alert').click(function() {
    $('div.quick-alert')
    .fadeIn('slow')
    <strong>.delay(3000)</strong>
    .fadeOut('slow');
  });
});
</code></pre>
<p>The only extra code is in bold &mdash; which makes your supermarket analogy seem like a stretch at best.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Kougioulis</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-83465</link>
		<dc:creator>Nick Kougioulis</dc:creator>
		<pubDate>Sat, 12 Feb 2011 11:12:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-83465</guid>
		<description>why use all of this jquery when you can have the same result using this?

JQuery
&lt;pre&gt;&lt;code&gt;
$(document).ready(function(){
$(&quot;#show-alert&quot;).click(function(){
$(&quot;#quick-alert&quot;).fadeIn(&quot;slow&quot;).fadeOut(3000);
});
});&lt;/code&gt;&lt;/pre&gt;

HTML

&lt;pre&gt;&lt;code&gt;
-&gt;Button with and id of &quot;show-alert&quot; here&lt;--
&lt;div id=&quot;quick-alert&quot;&gt;Alert!Watch me before its too late!&lt;/div&gt;
&lt;/code&gt;&lt;/pre&gt;

CSS
&lt;pre&gt;&lt;code&gt;
#quick-alert {
 width: 150px;
height:60px;
   padding: .5px;
   background: #ffa;
   border: 1px solid #a00;
   color: #a00;
   font-weight: bold;
   display: none;
}&lt;/code&gt;&lt;/pre&gt;

Just wondering why,would be really thankful if someone answers this.
Its like you can head to the supermarket by following road 1 which is full of corners ,when you can use road 2 which is a straight line.</description>
		<content:encoded><![CDATA[<p>why use all of this jquery when you can have the same result using this?</p>
<p>JQuery</p>
<pre><code>
$(document).ready(function(){
$("#show-alert").click(function(){
$("#quick-alert").fadeIn("slow").fadeOut(3000);
});
});</code></pre>
<p>HTML</p>
<pre><code>
-&gt;Button with and id of "show-alert" here&lt;--
<div id="quick-alert">Alert!Watch me before its too late!</div>

</code></pre>
<p>CSS</p>
<pre><code>
#quick-alert {
 width: 150px;
height:60px;
   padding: .5px;
   background: #ffa;
   border: 1px solid #a00;
   color: #a00;
   font-weight: bold;
   display: none;
}</code></pre>
<p>Just wondering why,would be really thankful if someone answers this.<br />
Its like you can head to the supermarket by following road 1 which is full of corners ,when you can use road 2 which is a straight line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Swedberg</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-80370</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Tue, 25 May 2010 13:10:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-80370</guid>
		<description>Seriously? You consider that a mistake in the &lt;em&gt;code&lt;/em&gt;? I &lt;em&gt;might&lt;/em&gt; grant you that it&#039;s a typographical mistake, but it hardly warrants a mention here. By the way, tell me if you can see any difference between this:
&#039;
and this:
&apos;

I can&#039;t. Now view source. The second one uses &apos;, which as far as I can tell, is meant for apostrophes.

Anyway, thanks for this little diversion.</description>
		<content:encoded><![CDATA[<p>Seriously? You consider that a mistake in the <em>code</em>? I <em>might</em> grant you that it&#8217;s a typographical mistake, but it hardly warrants a mention here. By the way, tell me if you can see any difference between this:<br />
&#8216;<br />
and this:<br />
&apos;</p>
<p>I can&#8217;t. Now view source. The second one uses &amp;apos;, which as far as I can tell, is meant for apostrophes.</p>
<p>Anyway, thanks for this little diversion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ant</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-80366</link>
		<dc:creator>Ant</dc:creator>
		<pubDate>Tue, 25 May 2010 08:27:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-80366</guid>
		<description>You have something wrong in code:
&lt;code&gt;$(&#039;&lt;div class=&quot;quick-alert&quot;&gt;Alert! Watch me before it\&#039;s too late!&lt;/div&gt;&#039;)&lt;/code&gt;

You should type it’s, not it&#039;s. ’ is not single quote. Qutes used for, uh, quotations. It’sapostrophecalled&lt;code&gt;&#160;&lt;/code&gt;&lt;em&gt;apostrophe&lt;/em&gt;.</description>
		<content:encoded><![CDATA[<p>You have something wrong in code:<br />
<code>$('&lt;div class="quick-alert"&gt;Alert! Watch me before it\'s too late!&lt;/div&gt;')</code></p>
<p>You should type it’s, not it&#8217;s. ’ is not single quote. Qutes used for, uh, quotations. It’sapostrophecalled<code>&nbsp;</code><em>apostrophe</em>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jutas</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-79767</link>
		<dc:creator>Jutas</dc:creator>
		<pubDate>Tue, 02 Mar 2010 23:27:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-79767</guid>
		<description>That&#039;s pretty easy and short! Thanks!</description>
		<content:encoded><![CDATA[<p>That&#8217;s pretty easy and short! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anirniq</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-79448</link>
		<dc:creator>Anirniq</dc:creator>
		<pubDate>Thu, 31 Dec 2009 13:33:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-79448</guid>
		<description>Hi. I always made like so :

&lt;code&gt;.fadeIn(&quot;medium&quot;, function() { setTimeout(&quot;$j(&#039;#comwarning&#039;).fadeOut(&#039;slow&#039;)&quot;, 3000) } );&lt;/code&gt;

A little less jQuery-likely, but contained in one line :)

See you</description>
		<content:encoded><![CDATA[<p>Hi. I always made like so :</p>
<p><code>.fadeIn("medium", function() { setTimeout("$j('#comwarning').fadeOut('slow')", 3000) } );</code></p>
<p>A little less jQuery-likely, but contained in one line :)</p>
<p>See you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobz</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-79100</link>
		<dc:creator>Tobz</dc:creator>
		<pubDate>Fri, 23 Oct 2009 10:13:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-79100</guid>
		<description>This doesn&#039;t seem to work in IE8, I had to put the tag below in:
&lt;code&gt;&lt;META HTTP-EQUIV=&quot;X-UA-Compatible&quot; CONTENT=&quot;IE=7&quot;&gt;&lt;/code&gt;

Is there a fix? Really like the code, thank you...</description>
		<content:encoded><![CDATA[<p>This doesn&#8217;t seem to work in IE8, I had to put the tag below in:<br />
<code>&lt;META HTTP-EQUIV="X-UA-Compatible" CONTENT="IE=7"&gt;</code></p>
<p>Is there a fix? Really like the code, thank you&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diana</title>
		<link>http://www.learningjquery.com/2007/01/effect-delay-trick/comment-page-1#comment-79037</link>
		<dc:creator>Diana</dc:creator>
		<pubDate>Mon, 12 Oct 2009 21:43:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/01/effect-delay-trick#comment-79037</guid>
		<description>great example and explanation.

I&#039;m adapting this as a way to prevent doubleclicking a submit button, without locking down the button permanently, because we have validation on the form, so it may need to be resubmitted.
&lt;pre&gt;&lt;code&gt;
$(document).ready(function() {
		$(&#039;:submit&#039;).click(function() {
			$original = $(this).val();
			$(this).val(&#039;Saving, please wait...&#039;)
			.attr(&quot;disabled&quot;,&quot;disabled&quot;)
			.fadeIn(&#039;slow&#039;)
			.animate({opacity: 0.4}, 4000)
			.fadeIn(&#039;slow&#039;, function() {
				$(this).val($original).removeAttr(&quot;disabled&quot;).animate({opacity: 1}, 2000)		
			});
		});
});
&lt;/code&gt;&lt;/pre&gt;

my problem is that it&#039;s conflicting with the Jquery validation plugin: prevents it from showing its error spans.</description>
		<content:encoded><![CDATA[<p>great example and explanation.</p>
<p>I&#8217;m adapting this as a way to prevent doubleclicking a submit button, without locking down the button permanently, because we have validation on the form, so it may need to be resubmitted.</p>
<pre><code>
$(document).ready(function() {
		$(':submit').click(function() {
			$original = $(this).val();
			$(this).val('Saving, please wait...')
			.attr("disabled","disabled")
			.fadeIn('slow')
			.animate({opacity: 0.4}, 4000)
			.fadeIn('slow', function() {
				$(this).val($original).removeAttr("disabled").animate({opacity: 1}, 2000)
			});
		});
});
</code></pre>
<p>my problem is that it&#8217;s conflicting with the Jquery validation plugin: prevents it from showing its error spans.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced (User agent is rejected)
Database Caching 11/24 queries in 0.008 seconds using disk: basic
Object Caching 374/387 objects using disk: basic
Content Delivery Network via learningjquery.kswedberg.netdna-cdn.com

Served from: www.learningjquery.com @ 2012-02-08 13:39:54 -->
