{"id":2095,"date":"2009-10-22T19:02:38","date_gmt":"2009-10-22T23:02:38","guid":{"rendered":"http:\/\/www.andysowards.com\/blog\/?p=2095"},"modified":"2009-10-22T19:02:38","modified_gmt":"2009-10-22T23:02:38","slug":"how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial","status":"publish","type":"post","link":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/","title":{"rendered":"How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial"},"content":{"rendered":"<p>Welcome back to part 3 of Adding Flair to your Actions with jQuery! If you missed <a href=\"https:\/\/andysowards.com\/blog\/tutorials\/how-to-add-flair-to-your-actions-with-jquery-part-2-javascript-tutorial\/\">Part 2<\/a>, go ahead and read that first, or just move ahead!<\/p>\n<h2>Simultaneous versus queued effects <\/h2>\n<p>The <i>.animate() <\/i> method, as we&#8217;ve just discovered, is very useful for creating simultaneous effects in a particular set of elements. There may be times, however, when we want to <b>queue <\/b> our effects, having them occur one after the other. <\/p>\n<h2>Working with a single set of elements <\/h2>\n<p>When applying multiple effects to the same set of elements, <b>queuing <\/b> is easily achieved by chaining those effects. To demonstrate this queuing, we&#8217;ll again move the <b>Text Size <\/b> box to the right, increase its height and increase its border width. This time, however, we perform the three effects sequentially, simply by placing each in its own <i>.animate() <\/i> method and chaining the three together: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>  $('div.label').click(function() { <br\/>    var paraWidth = $('div.speech p').outerWidth(); <br\/>    var $switcher = $(this).parent(); <br\/>    var switcherWidth = $switcher.outerWidth(); <br\/>    $switcher <br\/> <span style=\"font-weight: bold;\">.animate({left: paraWidth - switcherWidth}, <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">                                            'slow') <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">      .animate({height: '+=20px'}, 'slow') <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">      .animate({borderWidth: '5px'}, 'slow'); <\/span> <br\/>  }); <br\/>}); <br\/> <\/pre>\n<p>Chaining permits us to keep all three <i>.animate() <\/i> methods on the same line, but here we have indented them and put each on its own line for greater readability. <\/p>\n<p>We can queue any of the jQuery effect methods, not just <i>.animate() <\/i>, by chaining them. We can, for example, queue effects on in the following order: <\/p>\n<ol>\n<li>Fade its opacity to .5 with <i>.fadeTo() <\/i>. <\/li>\n<li>Move it to the right with <i>.animate() <\/i>. <\/li>\n<li>Fade it back in to full opacity with <i>.fadeTo() <\/i>. <\/li>\n<li>Hide it with <i>.slideUp() <\/i>. <\/li>\n<li>Show it once more with <i>.slideDown() <\/i>. <\/li>\n<\/ol>\n<p>All we need to do is chain the effects in the same order in our code: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>    $('div.label').click(function() { <br\/>      var paraWidth = $('div.speech p').outerWidth(); <br\/>      var $switcher = $(this).parent(); <br\/>      var switcherWidth = $switcher.outerWidth(); <br\/>      $switcher <br\/> <span style=\"font-weight: bold;\">.fadeTo('fast',0.5) <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        .animate({ <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">          'left': paraWidth - switcherWidth <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        }, 'slow') <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        .fadeTo('slow',1.0) <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        .slideUp('slow') <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        .slideDown('slow'); <\/span> <br\/>    }); <br\/>}); <br\/> <\/pre>\n<p>But what if we want to move the to the right at the same time as it fades to half opacity? If the two animations were occurring at the same speed, we could simply combine them into a single <i>.animate() <\/i> method. But in this example, the fade is using the <i>&#8216;fast&#8217; <\/i> speed while the move to the right is using the <i>&#8216;slow&#8217; <\/i> speed. Here is where the second form of the <i>.animate() <\/i> method comes in handy: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>    $('div.label').click(function() { <br\/>      var paraWidth = $('div.speech p').outerWidth(); <br\/>      var $switcher = $(this).parent(); <br\/>      var switcherWidth = $switcher.outerWidth(); <br\/>      $switcher <br\/>        .fadeTo('fast',0.5) <br\/> <span style=\"font-weight: bold;\">.animate({ <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">          'left': paraWidth - switcherWidth <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        }, {duration: 'slow', queue: false}) <\/span> <br\/>        .fadeTo('slow',1.0) <br\/>        .slideUp('slow') <br\/>        .slideDown('slow'); <br\/>    }); <br\/>}); <br\/> <\/pre>\n<p>The second argument, an options map, provides the <i>queue <\/i> option, which when set to <i>false <\/i> makes the animation start simultaneously with the previous one. <\/p>\n<p>One final observation about queuing effects on a single set of elements is that queuing does not automatically apply to other, non-effect methods such as <i>.css() <\/i>. So let&#8217;s suppose we wanted to change the background color of to red after the <i>.slideUp() <\/i> but before the <i>slideDown() <\/i>. We could try doing it like this: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>$('div.label').click(function() { <br\/>      var paraWidth = $('div.speech p').outerWidth(); <br\/>      var $switcher = $(this).parent(); <br\/>      var switcherWidth = $switcher.outerWidth(); <br\/>      $switcher <br\/>        .fadeTo('fast',0.5) <br\/>        .animate({ <br\/>          'left' paraWidth - switcherWidth <br\/>        }, 'slow') <br\/>        .fadeTo('slow',1.0) <br\/>        .slideUp('slow') <br\/> <span style=\"font-weight: bold;\">.css('backgroundColor','#f00') <\/span> <br\/>        .slideDown('slow'); <br\/>      }); <br\/>}); <br\/> <\/pre>\n<p>However, even though the background-changing code is placed at the correct position in the chain, it occurs immediately upon the click. <\/p>\n<p>One way we can add non-effect methods to the queue is to use the appropriately named <i>.queue() <\/i> method. Here is what it would look like in our example: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>    $('div.label').click(function() { <br\/>      var paraWidth = $('div.speech p').outerWidth(); <br\/>      var $switcher = $(this).parent(); <br\/>      var switcherWidth = $switcher.outerWidth(); <br\/>      $switcher <br\/>        .fadeTo('fast',0.5) <br\/>        .animate({ <br\/>          'left': paraWidth - switcherWidth <br\/>        }, 'slow') <br\/>        .fadeTo('slow',1.0) <br\/>        .slideUp('slow') <br\/> <span style=\"font-weight: bold;\">.queue(function() { <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">          $switcher <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">            .css('backgroundColor', '#f00') <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">            .dequeue(); <\/span> <br\/>        }) <br\/>        .slideDown('slow'); <br\/>    }); <br\/>}); <br\/> <\/pre>\n<p>When given a <b>callback function <\/b>, as it is here, the <i>.queue() <\/i> method adds the function to the queue of effects for the matched elements. Within the function, we set the background color to red and then add the corollary <i>.dequeue() <\/i> method. Including this <i>.dequeue() <\/i> method allows the animation queue to pick up where it left off and complete the chain with the following <i>.slideDown(&#8216;slow&#8217;) <\/i> line. If we hadn&#8217;t used .dequeue(), the animation would have stopped. <\/p>\n<p style=\"margin-left: 20px; margin-right: 20px;\"> <em>More information and examples for .queue() and .dequeue() are available at <a href=\"http:\/\/docs.jquery.com\/Effects\" target=\"_blank\">http:\/\/docs.jquery.com\/Effects <\/a>. <\/em> <\/p>\n<p>We&#8217;ll discover another way to queue non-effect methods as we examine effects with multiple sets of elements. <\/p>\n<h2>Working with multiple sets of elements <\/h2>\n<p>Unlike with a single set of elements, when we apply effects to different sets, they occur at virtually the same time. To see these simultaneous effects in action, we&#8217;ll slide one paragraph down while sliding another paragraph up. First, we&#8217;ll add the remaining portion of the Gettysburg Address to the HTML, dividing it into two separate paragraphs: <\/p>\n<pre style=\"margin-left: 20px;\"> <div id=\"switcher\"> <br\/> <div class=\"label\">Text Size <\/div> <br\/> <button id=\"switcher-default\">Default <\/button> <br\/> <button id=\"switcher-large\">Bigger <\/button> <br\/> <button id=\"switcher-small\">Smaller <\/button> <br\/> <\/div> <br\/> <div class=\"speech\"> <br\/> <p>Fourscore and seven years ago our fathers brought forth <br\/>     on this continent a new nation, conceived in liberty, and <br\/>     dedicated to the proposition that all men are created <br\/>     equal. <br\/> <\/p> <br\/> <p>Now we are engaged in a great civil war, testing whether <br\/>     that nation, or any nation so conceived and so dedicated, <br\/>     can long endure. We are met on a great battlefield of <br\/>     that war. We have come to dedicate a portion of that <br\/>     field as a final resting-place for those who here gave <br\/>     their lives that the nation might live. It is altogether <br\/>     fitting and proper that we should do this. But, in a <br\/>     larger sense, we cannot dedicate, we cannot consecrate, <br\/>     we cannot hallow, this ground. <br\/> <\/p> <br\/> <a href=\"#\" class=\"more\">read more <\/a> <br\/> <span style=\"font-weight: bold;\"> <p>The brave men, living and dead, who struggled <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     here have consecrated it, far above our poor <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     power to add or detract. The world will little <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     note, nor long remember, what we say here, but it <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     can never forget what they did here. It is for us <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     the living, rather, to be dedicated here to the <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     unfinished work which they who fought here have <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     thus far so nobly advanced. <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\"> <\/p> <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\"> <p>It is rather for us to be here dedicated to the <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     great task remaining before us\u00e2\u20ac\u201dthat from <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     these honored dead we take increased devotion to <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     that cause for which they gave the last full <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     measure of devotion\u00e2\u20ac\u201dthat we here highly <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     resolve that these dead shall not have died in <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     vain\u00e2\u20ac\u201dthat this nation, under God, shall <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     have a new birth of freedom and that government <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     of the people, by the people, for the people, <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">     shall not perish from the earth. <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\"> <\/p> <\/span> <br\/> <\/div> <br\/> <\/pre>\n<p>Next, to help us see what&#8217;s happening during the effect, we&#8217;ll give the third paragraph a 1-pixel border and the fourth paragraph a gray background. We&#8217;ll also hide the fourth paragraph when the DOM is ready: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>  $('p:eq(2)').css('border', '1px solid #333'); <br\/>  $('p:eq(3)').css('backgroundColor', '#ccc').hide(); <br\/>}); <br\/> <\/pre>\n<p>Finally, we&#8217;ll add the <i>.click() <\/i> method to the third paragraph so that when it is clicked, the third paragraph will slide up (and out of view), while the fourth paragraph slides down (and into view): <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>$('p:eq(2)') <br\/>    .css('border', '1px solid #333') <br\/> <span style=\"font-weight: bold;\">.click(function() { <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">      $(this).slideUp('slow') <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        .next().slideDown('slow'); <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">    }); <\/span> <br\/>  $('p:eq(3)').css('backgroundColor', '#ccc').hide(); <br\/>}); <br\/> <\/pre>\n<p>A screenshot of these two effects in mid-slide confirms that they do, indeed, occur virtually simultaneously: <\/p>\n<p style=\"text-align: center;\"> <img decoding=\"async\" data-src=\"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/> <\/p>\n<p>The third paragraph, which started visible, is halfway through sliding up at the same time as the fourth paragraph, which started hidden, is halfway through sliding down. <\/p>\n<h2>Callbacks <\/h2>\n<p>In order to allow queuing effects on different elements, jQuery provides a <b>callback function <\/b> for each effect method. As we have seen with event handlers and with the <i>.queue() <\/i> method, callbacks are simply functions passed as method arguments. In the case of effects, they appear as the last argument of the method. <\/p>\n<p>If we use a callback to queue the two slide effects, we can have the fourth paragraph slide down before the third paragraph slides up. Let&#8217;s first look at how to set up the <i>.slideDown() <\/i> method with the callback: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>  $('p:eq(2)') <br\/>    .css('border', '1px solid #333') <br\/>    .click(function() { <br\/> <span style=\"font-weight: bold;\">$(this).next().slideDown('slow',function() { <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        \/\/ code here executes after 3rd paragraph's <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        \/\/ slide down has ended <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">    }); <\/span> <br\/>  }); <br\/>  $('p:eq(3)').css('backgroundColor', '#ccc').hide(); <br\/> }); <br\/> <\/pre>\n<p>We do need to be careful here, however, about what is actually going to slide up. The context has changed for <i>$(this) <\/i> because the callback is inside the <i>.slideDown() <\/i> method. Here, <i>$(this) <\/i> is no longer the third paragraph, as it was at the point of the <i>.click() <\/i> method; rather, since the <i>.slideDown() <\/i> method is attached to <i>$(this).next() <\/i>, everything within that method now sees <i>$(this) <\/i> as the next sibling, or the fourth paragraph. Therefore, if we put <i>$(this).slideUp(&#8216;slow&#8217;) <\/i> inside the callback, we would end up hiding the same paragraph that we had just made visible. <\/p>\n<p>A simple way to keep the reference of <i>$(this) <\/i> stable is to store it in a variable right away within the <i>.click() <\/i> method, like <i>var $thirdPara = $(this) <\/i>. <\/p>\n<p>Now <i>$thirdPara <\/i> will refer to the third paragraph, both outside and inside the callback. Here is what the code looks like using our new variable: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/> <span style=\"font-weight: bold;\">var $thirdPara = $('p:eq(2)'); <\/span> <br\/>  $thirdPara <br\/>    .css('border', '1px solid #333') <br\/> <span style=\"font-weight: bold;\">.click(function() { <\/span> <br\/>      $(this).next().slideDown('slow',function() { <br\/> <span style=\"font-weight: bold;\">$thirdPara.slideUp('slow'); <\/span> <br\/>      }); <br\/>    }); <br\/>  $('p:eq(3)').css('backgroundColor', '#ccc').hide(); <br\/>}); <br\/> <\/pre>\n<p>Using <i>$thirdPara <\/i> inside the <i>.slideDown() <\/i> callback relies on the properties of <b>closures <\/b>. <\/p>\n<p>This time a snapshot halfway through the effects will reveal that both the third and the fourth paragraphs are visible; the fourth has finished sliding down and the third is about to begin sliding up: <\/p>\n<p style=\"text-align: center;\"> <img decoding=\"async\" data-src=\"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image10.png\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/> <\/p>\n<p>Now that we&#8217;ve discussed callbacks, we can return to the code from earlier in this article in which we queued a background-color change near the end of a series of effects. Instead of using the <i>.queue() <\/i> method, as we did earlier, we can simply use a callback function: <\/p>\n<pre style=\"margin-left: 20px;\">$(document).ready(function() { <br\/>  $('div.label').click(function() { <br\/>    var paraWidth = $('div.speech p').outerWidth(); <br\/>    var $switcher = $(this).parent(); <br\/>    var switcherWidth = $switcher.outerWidth(); <br\/>    $switcher <br\/>      .fadeTo('slow',0.5) <br\/>      .animate({ <br\/>        'left': paraWidth - switcherWidth <br\/>      }, 'slow') <br\/>      .fadeTo('slow',1.0) <br\/> <span style=\"font-weight: bold;\">.slideUp('slow', function() { <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">        $switcher <\/span> <br style=\"font-weight: bold;\"\/> <span style=\"font-weight: bold;\">          .css('backgroundColor', '#f00'); <\/span> <br\/>      }) <br\/>      .slideDown('slow'); <br\/>  }); <br\/>}); <br\/> <\/pre>\n<p>Here again, the background color of changes to red after it slides up, and before it slides back down. <\/p>\n<h2>In a nutshell <\/h2>\n<p>With all the variations to consider when applying effects, it can become difficult to remember whether the effects will occur simultaneously or sequentially. A brief outline might help: <\/p>\n<ol>\n<li>Effects on a single set of elements are: <br \/>&#8212; <i>simultaneous <\/i> when applied as multiple properties in a single <i>.animate( <\/i>) method. <br \/> &#8212; <i>queued <\/i> when applied in a chain of methods, unless the queue option is set to <i>false <\/i>. <\/li>\n<li>Effects on multiple sets of elements are: <br \/> &#8212; <i>simultaneous <\/i> by default <br \/> &#8212; <i>queued <\/i> when applied within the callback of another effect or within the callback of the <i>.queue() <\/i> method <\/li>\n<\/ol>\n<h1>Summary <\/h1>\n<p>By using effect methods that we have explored in this article, we should now be able to incrementally increase and decrease text size by using either the <i>.css( <\/i>) or the <i>.animate() <\/i> method. We should also be able to apply various effects to gradually hide and show page elements in different ways and also to animate elements, simultaneously or sequentially, in a number of ways. <\/p>\n<p>  <!-- end part 3 --> <\/p>\n<hr size=\"1\" noshade=\"noshade\" color=\"#ff9933\"\/> <\/p>\n<div class=\"header\">Learning jQuery 1.3 <\/div>\n<div style=\"line-height: 0.4em;\">&#160; <\/div>\n<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"99\" valign=\"top\"> <a href=\"http:\/\/www.packtpub.com\/learning-jquery-1.3\/book\/mid\/240609o1fp7w\" target=\"_blank\"> <img decoding=\"async\" height=\"123\" width=\"99\" border=\"0\" data-src=\"http:\/\/images.packtpub.com\/images\/100x123\/1847196705.png\" alt=\"Learning jQuery 1.3\" class=\"left lazyload\" title=\"Learning jQuery 1.3\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 99px; --smush-placeholder-aspect-ratio: 99\/123;\" \/> <\/a> <\/td>\n<td valign=\"top\">\n<ul>\n<li>Better Interaction Design and Web Development with Simple JavaScript Techniques <\/li>\n<li>An introduction to jQuery that requires minimal programming experience <\/li>\n<li>Detailed solutions to specific client-side problems <\/li>\n<li>For web designers to create interactive elements for their designs <\/li>\n<li>For developers to create the best user interface for their web applications <\/li>\n<li>Packed with great examples, code, and clear explanations <\/li>\n<li>Revised and updated version of the first book to help you learn jQuery <\/li>\n<\/ul>\n<p>&#160;&#160; <a href=\"http:\/\/www.packtpub.com\/learning-jquery-1.3\/book\/mid\/240609o1fp7w\" target=\"_blank\">http:\/\/www.packtpub.com\/learning-jquery-1.3\/book <\/a> <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> <\/p>\n<hr size=\"1\" noshade=\"noshade\" color=\"#ff9933\"\/>\n","protected":false},"excerpt":{"rendered":"<p>Welcome back to part 3 of Adding Flair to your Actions with jQuery! If you missed Part 2, go ahead and read that first, or just move ahead! Simultaneous versus<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[73,202,844,34],"tags":[2313,1967,2579,542,962,5885,178,2115,2575,2653,201,5889,5896,2656,433,238,2546,2576,2655,5888,755,87,460,2654,2658,115,459,84,5886,5890,2657,1524],"class_list":["post-2095","post","type-post","status-publish","format-standard","hentry","category-javascript","category-jquery","category-popular","category-tutorials","tag-1-3","tag-add","tag-adding","tag-article","tag-book","tag-design","tag-development","tag-elements","tag-flair","tag-flare","tag-java","tag-javascript","tag-jquery","tag-jquery1-3","tag-js","tag-learning","tag-packt","tag-part","tag-part3","tag-programming","tag-publishing","tag-script","tag-scripts","tag-series","tag-teach","tag-tips","tag-tricks","tag-tutorial","tag-tutorials","tag-web","tag-with","tag-working"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial<\/title>\n<meta name=\"description\" content=\"Welcome back to part 3 of Adding Flair to your Actions with jQuery! If you missed Part 2, go ahead and read that first, or just move ahead! Simultaneous\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-\u2013-part-3-\u2013-javascript-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial\" \/>\n<meta property=\"og:description\" content=\"Welcome back to part 3 of Adding Flair to your Actions with jQuery! If you missed Part 2, go ahead and read that first, or just move ahead! Simultaneous\" \/>\n<meta property=\"og:url\" content=\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-\u2013-part-3-\u2013-javascript-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Daily Business Resources for Entrepreneurs, Web Designers, &amp; Creatives by Andy Sowards\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/andysowardsfan\" \/>\n<meta property=\"article:published_time\" content=\"2009-10-22T23:02:38+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png\" \/>\n<meta name=\"author\" content=\"Packt Publishing\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@andysowards\" \/>\n<meta name=\"twitter:site\" content=\"@andysowards\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Packt Publishing\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/\",\"url\":\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/\",\"name\":\"How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/andysowards.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png\",\"datePublished\":\"2009-10-22T23:02:38+00:00\",\"dateModified\":\"2009-10-22T23:02:38+00:00\",\"author\":{\"@id\":\"https:\/\/andysowards.com\/blog\/#\/schema\/person\/4ba818a9b32b7936ec5e87769f9e7bf1\"},\"description\":\"Welcome back to part 3 of Adding Flair to your Actions with jQuery! If you missed Part 2, go ahead and read that first, or just move ahead! Simultaneous\",\"breadcrumb\":{\"@id\":\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#primaryimage\",\"url\":\"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png\",\"contentUrl\":\"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/andysowards.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/andysowards.com\/blog\/#website\",\"url\":\"https:\/\/andysowards.com\/blog\/\",\"name\":\"Daily Business Resources for Entrepreneurs, Web Designers, &amp; Creatives by Andy Sowards\",\"description\":\"Design Inspiration &amp; Business Resources for Creatives\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/andysowards.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/andysowards.com\/blog\/#\/schema\/person\/4ba818a9b32b7936ec5e87769f9e7bf1\",\"name\":\"Packt Publishing\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/andysowards.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a379fb7a779d99a17503144f504637e99d1017770f86477597009e6a850b1ce9?s=96&r=pg\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a379fb7a779d99a17503144f504637e99d1017770f86477597009e6a850b1ce9?s=96&r=pg\",\"caption\":\"Packt Publishing\"},\"description\":\"Hi, I'm Jude from Packt Publishing. We have a wide range of books covering various technologies such as Open Source and Enterprise. http:\/\/www.packtpub.com\/\",\"sameAs\":[\"http:\/\/www.packtpub.com\/\"],\"url\":\"https:\/\/andysowards.com\/blog\/author\/packtpublishing\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial","description":"Welcome back to part 3 of Adding Flair to your Actions with jQuery! If you missed Part 2, go ahead and read that first, or just move ahead! Simultaneous","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:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-\u2013-part-3-\u2013-javascript-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial","og_description":"Welcome back to part 3 of Adding Flair to your Actions with jQuery! If you missed Part 2, go ahead and read that first, or just move ahead! Simultaneous","og_url":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-\u2013-part-3-\u2013-javascript-tutorial\/","og_site_name":"Daily Business Resources for Entrepreneurs, Web Designers, &amp; Creatives by Andy Sowards","article_publisher":"http:\/\/facebook.com\/andysowardsfan","article_published_time":"2009-10-22T23:02:38+00:00","og_image":[{"url":"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png"}],"author":"Packt Publishing","twitter_card":"summary_large_image","twitter_creator":"@andysowards","twitter_site":"@andysowards","twitter_misc":{"Written by":"Packt Publishing","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/","url":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/","name":"How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial","isPartOf":{"@id":"https:\/\/andysowards.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#primaryimage"},"thumbnailUrl":"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png","datePublished":"2009-10-22T23:02:38+00:00","dateModified":"2009-10-22T23:02:38+00:00","author":{"@id":"https:\/\/andysowards.com\/blog\/#\/schema\/person\/4ba818a9b32b7936ec5e87769f9e7bf1"},"description":"Welcome back to part 3 of Adding Flair to your Actions with jQuery! If you missed Part 2, go ahead and read that first, or just move ahead! Simultaneous","breadcrumb":{"@id":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#primaryimage","url":"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png","contentUrl":"http:\/\/www.packtpub.com\/files\/images\/jquery_article1_image09.png"},{"@type":"BreadcrumbList","@id":"https:\/\/andysowards.com\/blog\/2009\/how-to-add-flair-to-your-actions-with-jquery-%e2%80%93-part-3-%e2%80%93-javascript-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/andysowards.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Add Flair to your Actions with jQuery \u00e2\u20ac\u201c Part 3 \u00e2\u20ac\u201c Javascript Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/andysowards.com\/blog\/#website","url":"https:\/\/andysowards.com\/blog\/","name":"Daily Business Resources for Entrepreneurs, Web Designers, &amp; Creatives by Andy Sowards","description":"Design Inspiration &amp; Business Resources for Creatives","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/andysowards.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/andysowards.com\/blog\/#\/schema\/person\/4ba818a9b32b7936ec5e87769f9e7bf1","name":"Packt Publishing","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/andysowards.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a379fb7a779d99a17503144f504637e99d1017770f86477597009e6a850b1ce9?s=96&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a379fb7a779d99a17503144f504637e99d1017770f86477597009e6a850b1ce9?s=96&r=pg","caption":"Packt Publishing"},"description":"Hi, I'm Jude from Packt Publishing. We have a wide range of books covering various technologies such as Open Source and Enterprise. http:\/\/www.packtpub.com\/","sameAs":["http:\/\/www.packtpub.com\/"],"url":"https:\/\/andysowards.com\/blog\/author\/packtpublishing\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/posts\/2095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/comments?post=2095"}],"version-history":[{"count":0,"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/posts\/2095\/revisions"}],"wp:attachment":[{"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/media?parent=2095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/categories?post=2095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andysowards.com\/blog\/wp-json\/wp\/v2\/tags?post=2095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}