<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>jquery on Curtis Timson</title><link>https://hugo.curtiscode.dev/tags/jquery/</link><description>Recent content in jquery on Curtis Timson</description><generator>Hugo -- gohugo.io</generator><language>en-GB</language><lastBuildDate>Mon, 05 May 2014 00:00:00 +0000</lastBuildDate><atom:link href="https://hugo.curtiscode.dev/tags/jquery/index.xml" rel="self" type="application/rss+xml"/><item><title>Namespacing jQuery event handlers</title><link>https://hugo.curtiscode.dev/post/jquery/namespacing-jquery-event-handlers/</link><pubDate>Mon, 05 May 2014 00:00:00 +0000</pubDate><guid>https://hugo.curtiscode.dev/post/jquery/namespacing-jquery-event-handlers/</guid><description>If we are to attach 2 or more event handlers to an element these will become stacked and run linear in the order they were attached.
For example:
$(&amp;#34;.foo&amp;#34;).on(&amp;#34;click&amp;#34;, function(e){ console.log(&amp;#34;bar&amp;#34;); }); $(&amp;#34;.foo&amp;#34;).on(&amp;#34;click&amp;#34;, function(e){ console.log(&amp;#34;baz&amp;#34;); }); If .foo is then clicked, the browser console will log:
&amp;#34;bar&amp;#34; &amp;#34;baz&amp;#34; If we wish to remove these event handlers we can call:
$(&amp;#34;.foo&amp;#34;).off(&amp;#34;click&amp;#34;); Simple.
However, what if we wish to only remove 1 of these event handlers and retain the other?</description></item><item><title>Understanding jQuery data() storage</title><link>https://hugo.curtiscode.dev/post/jquery/understanding-jquery-data-storage/</link><pubDate>Tue, 14 May 2013 00:00:00 +0000</pubDate><guid>https://hugo.curtiscode.dev/post/jquery/understanding-jquery-data-storage/</guid><description>It is a common misunderstanding that .data(&amp;quot;key&amp;quot;) is simply a shortcut for .attr(&amp;quot;data-key&amp;quot;).
.data() does read HTML5 data attributes, but this is only the first time it is called, as per the documentation:
The data- attributes are pulled in the first time the data property is accessed and then are no longer accessed or mutated (all data values are then stored internally in jQuery).
After they&amp;rsquo;ve been read once, they are then stored in jQuery&amp;rsquo;s cache object, $.</description></item><item><title>Creating a new rule for a CSS class in jQuery</title><link>https://hugo.curtiscode.dev/post/jquery/creating-a-new-rule-for-a-css-class-in-jquery/</link><pubDate>Sun, 07 Oct 2012 00:00:00 +0000</pubDate><guid>https://hugo.curtiscode.dev/post/jquery/creating-a-new-rule-for-a-css-class-in-jquery/</guid><description>In jQuery, to add a new style to all elements which have a particular CSS class, we can simply call a function like the following:
&amp;lt;div class=&amp;#34;foobar&amp;#34;&amp;gt;Lorem Ipsum&amp;lt;/div&amp;gt; &amp;lt;div class=&amp;#34;foobar&amp;#34;&amp;gt;Dolor sit amet&amp;lt;/div&amp;gt; function SetFooBarRed(){ $(&amp;#34;.foobar&amp;#34;).css(&amp;#34;background-color&amp;#34;, &amp;#34;red&amp;#34;); } This will add the style background-color:red to all elements with the class foobar.
&amp;lt;div class=&amp;#34;foobar&amp;#34; style=&amp;#34;background-color:red;&amp;#34;&amp;gt;Lorem Ipsum&amp;lt;/div&amp;gt; &amp;lt;div class=&amp;#34;foobar&amp;#34; style=&amp;#34;background-color:red;&amp;#34;&amp;gt;Dolor sit amet&amp;lt;/div&amp;gt; However, if we have elements which are loaded into the DOM after the initial page load, then these new elements will not have the new style automatically added to them (as they were not included within the DOM when SetFooBarRed() was called).</description></item><item><title>Using jQuery callback functions</title><link>https://hugo.curtiscode.dev/post/jquery/using-jquery-callback-functions/</link><pubDate>Sun, 05 Aug 2012 00:00:00 +0000</pubDate><guid>https://hugo.curtiscode.dev/post/jquery/using-jquery-callback-functions/</guid><description>I’ve heard questions in the past regarding how to run a script after a jQuery animation or event has been completed.
The majority of these believe that you need to delay the script for a few seconds, allowing the animation to complete before the 2nd function is called. For example:
$foo.load(&amp;#34;MyWebPage.html&amp;#34;); $foo.delay(1000).css(&amp;#34;color&amp;#34;, &amp;#34;red&amp;#34;); Here, the jQuery object $foo is being loaded with a web page’s content, then while this is happening a delay of 1000 milliseconds is set, before the css colour is changed to red.</description></item></channel></rss>