<?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>Creative Individual Design Blog &#187; jQuery</title>
	<atom:link href="https://creativeindividual.co.uk/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>https://creativeindividual.co.uk</link>
	<description>A Place of Inspiration</description>
	<lastBuildDate>Wed, 21 Aug 2019 17:33:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4</generator>
		<item>
		<title>Create a jQuery Tooltip!</title>
		<link>https://creativeindividual.co.uk/2012/11/create-a-jquery-tooltip/</link>
		<comments>https://creativeindividual.co.uk/2012/11/create-a-jquery-tooltip/#comments</comments>
		<pubDate>Sun, 25 Nov 2012 13:40:55 +0000</pubDate>
		<dc:creator>Laura Montgomery</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://creativeindividual.co.uk/?p=361</guid>
		<description><![CDATA[<a href="/2012/11/create-a-jquery-tooltip" title="Create a jQuery Tooltip"><img src="/wp-content/uploads/2012/11/banner.jpg" /></a>

In this article I am going to show you how to create a simple <strong>Tooltip</strong> effect using jQuery. What's great about this method is that it degrades gracefully, so if someone doesn't have Javascript enabled they don't see anything out of place.

The tooltip that we will be creating will appear when we hover over a link. We will use the HTML5 <strong>custom data attribute</strong> (data-*) to hold our information, then use jQuery to dynamically create a container (div) to hold the information within the custom data attribute.

This tutorial assumes that you have some understanding of jQuery but I'll be explaining everything as we go so should be good for beginners as well. You will also need to understand HTML and CSS.]]></description>
			<content:encoded><![CDATA[<p>In this article I am going to show you how to create a simple <strong>Tooltip</strong> effect using <a title="jQuery - Category" href="/category/jquery/">jQuery</a>. What&#8217;s great about this method is that it degrades gracefully, so if someone doesn&#8217;t have Javascript enabled they don&#8217;t see anything out of place.</p>
<p>This tutorial assumes that you have some understanding of jQuery but I&#8217;ll be explaining everything as we go so should be good for beginners as well. You will also need to understand HTML and CSS.</p>
<p>I&#8217;ve included the finished files and a demo so you can see what we are going to achieve.</p>
<h2>The Technique</h2>
<p>The tooltip that we will be creating will appear when we hover over a link. We will use the HTML5 <a title="HTML5 custom data attributes" href="http://dev.w3.org/html5/spec/global-attributes.html#embedding-custom-non-visible-data-with-the-data-*-attributes">custom data attribute</a> (data-*) to hold our information, then use jQuery to dynamically create a container (div) to hold the information within the custom data attribute.</p>
<h2>Tutorial Demo</h2>
<p>Still not sure what we are trying to achieve? Just click the image below to view the demo:</p>
<p><a href="http://creativeindividual.co.uk/wp-content/uploads/2012/tooltip/"><img class="alignnone size-full wp-image-362" title="Create a jQuery Tooltip - Tutorial Demo" src="http://creativeindividual.co.uk/wp-content/uploads/2012/11/preview.jpg" alt="Create a jQuery Tooltip - Tutorial Demo" width="648" height="406" /></a></p>
<div class="view-tutorial-demo"><a title="Create a jQuery Tooltip - Tutorial Demo" href="http://creativeindividual.co.uk/wp-content/uploads/2012/tooltip/">View the Tutorial Demo</a></div>
<h2>The HTML</h2>
<p>OK, first create a new HTML file and insert the usual DOCTYPE, html, head, etc. information. Notice I am using the HTML5 DOCTYPE.</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;title&gt;Tooltip Demo&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Add links to your CSS and Tooltip JS files, and create these files. I&#8217;ve used <strong>layout.css</strong> and <strong>tooltip.js</strong> respectively. You will also need to link to a hosted jQuery library or host your own. I personally prefer to link to Google but use whichever option is best for you and your project.</p>
<pre>...
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;title&gt;Tooltip Demo&lt;/title&gt;
    &lt;link rel="stylesheet" href="layout.css" type="text/css" /&gt;
    &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="tooltip.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
...</pre>
<p>Now, add a link (&lt;a href&#8230;) with all the usual attributes. I am using the hash symbol (#) because this is a test and I don&#8217;t want this link to go anywhere but this script works perfectly with real links.</p>
<pre>...
&lt;body&gt;
  &lt;a href="#" title="My Link Title"&gt;My Link&lt;/a&gt;
&lt;/body&gt;
...</pre>
<p>Finally, add our custom data attribute. For readability I am using <strong>data-tooltip</strong> but feel free to use something which better describes your content.</p>
<pre>...
&lt;body&gt;
  &lt;a href="#" title="My Link Title" data-tooltip="My Tooltip Text"&gt;My Link&lt;/a&gt;
&lt;/body&gt;
...</pre>
<p>And that&#8217;s it for the HTML. Pretty simple right? The CSS is even easier&#8230;</p>
<h2>The CSS</h2>
<p>Our tooltip will have an <strong>ID of tooltip</strong>. This isn&#8217;t obvious from the HTML because this div will be created dynamically by our jQuery script, so just take my word for it for now &#8211; all will become clear in a minute. For our CSS we actually only need to add two styles to <strong>div#tooltip</strong> for the basic tooltip effect, <strong>position</strong> and <strong>z-index</strong>. Add the following to <strong>layout.css</strong>:</p>
<pre>div#tooltip {
  position: absolute;
  z-index: 10;
}</pre>
<p>In the demo (and downloadable files) I&#8217;ve also added some basic styling such as background, color, padding and even box shadow to improve the effect, but I&#8217;ll leave this up to you to style the tooltip to suit your site design.</p>
<h2>The jQuery</h2>
<p>Open up <strong>tooltip.js</strong> and write out the document ready function &#8211; feel free to use the shorter version but for readability I will use the full function.</p>
<pre>$(document).ready(function() {
});</pre>
<p>Next we want to target any element with an attribute of <strong>data-tooltip</strong>, so this will be our selector. The action will be <strong>.hover</strong>.</p>
<pre>$(document).ready(function() {
  $("[data-tooltip]").hover(
    function() {
    }
  );
});</pre>
<p>We first want to create the div which will hold our tooltip information. Remember from above that this will be a div with an ID of tooltip. We will use <strong>.before</strong> to position this div before our link in the DOM. This is why position and z-index are so important in our CSS &#8211; these position the tooltip div visually above our link (and other content) and stops any nasty content jumping from occurring. <em>Note the single quotes used.</em></p>
<pre>$(document).ready(function() {
  $("[data-tooltip]").hover(
    function() {
      $(this).before('&lt;div id="tooltip"&gt;&lt;/div&gt;')
    }
  );
});</pre>
<p>Next we want to get the information from our data attribute and store it in a variable. I have put this variable above the previous line which is good practice, especially in cases where I would be using more than one variable, i.e. keeping them together.</p>
<pre>$(document).ready(function() {
  $("[data-tooltip]").hover(
    function() {
      var tooltip = $(this).attr("data-tooltip");
      $(this).before('&lt;div id="tooltip"&gt;&lt;/div&gt;')
    }
  );
});</pre>
<p>Finally, we want to add the information stored in our variable to our new div. We can use <strong>.text</strong> to achieve this.</p>
<pre>$(document).ready(function() {
  $("[data-tooltip]").hover(
    function() {
      var tooltip = $(this).attr("data-tooltip");
      $(this).before('&lt;div id="tooltip"&gt;&lt;/div&gt;')
      $("div#tooltip").text(tooltip);
    }
  );
});</pre>
<p>If you have any basic knowledge of jQuery you will know that <strong>.hover</strong> also includes <strong>hover off</strong> within the action. Let&#8217;s make use of that now to delete the tooltip div when we move our mouse cursor off the link. We simply need to use <strong>.remove</strong> to achieve this.</p>
<pre>$(document).ready(function() {
  $("[data-tooltip]").hover(
    function() {
      var tooltip = $(this).attr("data-tooltip");
      $(this).before('&lt;div id="tooltip"&gt;&lt;/div&gt;')
      $("div#tooltip").text(tooltip);
    },
    function() {
      $("div#tooltip").remove();
    }
  );
});</pre>
<p>We are almost done. The last part is to get the tooltip div to follow our mouse cursor as it moves around the link. I have used a similar effect in a <a title="Create a Pop-up div in jQuery" href="http://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/">previous post</a>. First we want to create two variables which will tell the div how far away from our cursor to move so that we can easily see all of the text.</p>
<pre>$(document).ready(function() {
  var moveLeft = 20;
  var moveDown = 10;
  $("[data-tooltip]").hover(
    ...
  );
});</pre>
<p>The action of the tooltip div moving occurs when we move our mouse cursor around on the link with the data attribute, so this is what we will be targeting with the <strong>.mousemove</strong> action.</p>
<pre>$(document).ready(function() {
  var moveLeft = 20;
  var moveDown = 10;
  $("[data-tooltip]").hover(
    ...
  );
  $("data-tooltip").mousemove(function() {
  });
});</pre>
<p>We then just need to use <strong>.css</strong> on our tooltip div to move it from the <strong>top</strong> and from the <strong>left</strong> &#8211; remember that we used <strong>position: absolute</strong> in our CSS, this is coming into play again.</p>
<pre>$(document).ready(function() {
  var moveLeft = 20;
  var moveDown = 10;
  $("[data-tooltip]").hover(
    ...
  );
  $("data-tooltip").mousemove(function() {
    $("div#tooltip").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
  });
});</pre>
<p>We have one small update to do to our code to finish. Notice the <strong>e</strong> used  - i.e. e.pageY and e.pageX. We simply need to add e between the parenthesis of each of our functions. See the full complete code below:</p>
<pre>$(document).ready(function() {
  var moveLeft = 20;
  var moveDown = 10;
  $("[data-tooltip]").hover(
    function(e) {
      var tooltip = $(this).attr("data-tooltip");
      $(this).before('&lt;div id="tooltip"&gt;&lt;/div&gt;')
      $("div#tooltip").text(tooltip);
    },
    function(e) {
      $("div#tooltip").remove();
    }
  );
  $("[data-tooltip]").mousemove(function(e) {
    $("div#tooltip").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
  });
});</pre>
<p>Load up your HTML page and check out the script in action.</p>
<p><strong>That&#8217;s it!</strong></p>
<p><a href="http://creativeindividual.co.uk/wp-content/uploads/2012/tooltip/"><img class="alignnone size-full wp-image-362" title="Create a jQuery Tooltip - Tutorial Demo" src="http://creativeindividual.co.uk/wp-content/uploads/2012/11/preview.jpg" alt="Create a jQuery Tooltip - Tutorial Demo" width="648" height="406" /></a></p>
<div class="view-tutorial-demo"><a title="Create a jQuery Tooltip - Tutorial Demo" href="http://creativeindividual.co.uk/wp-content/uploads/2012/tooltip/">View the Tutorial Demo</a></div>
<h2>Get The Source Code</h2>
<p>You can download the complete tutorial source code by clicking on the big button below and unzipping the file.</p>
<p><a href="http://creativeindividual.co.uk/wp-content/uploads/2012/tooltip/tooltip.zip"><img class="alignnone size-full wp-image-108" title="Download Source File - jQuery Tutorial - Create a jQuery Tooltip" src="http://creativeindividual.co.uk/wp-content/uploads/2010/11/download-source-file.png" alt="" width="648" height="104" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://creativeindividual.co.uk/2012/11/create-a-jquery-tooltip/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>jQuery 101 &#8211; Learning the Basics</title>
		<link>https://creativeindividual.co.uk/2012/06/jquery-101-learning-the-basics/</link>
		<comments>https://creativeindividual.co.uk/2012/06/jquery-101-learning-the-basics/#comments</comments>
		<pubDate>Sun, 17 Jun 2012 17:26:52 +0000</pubDate>
		<dc:creator>Laura Montgomery</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://creativeindividual.co.uk/?p=354</guid>
		<description><![CDATA[<a href="/2012/06/jquery-101-learning-the-basics/" title="jQuery 101 - Learning the Basics"><img src="/wp-content/uploads/2010/10/jquery_banner.jpg" /></a>

By now most web designers and developers have a very good understanding of jQuery and its capabilities; for most it is their go to JavaScript library when adding some additional functionality or interactivity to their web pages.

However there are still plenty of people out there who are new to web development and who would like to get started with this great language but don’t know how to.

<em>Well, this one’s for you!</em>

In this tutorial aimed at absolute jQuery beginners you'll learn about:

<ul>
<li>What is jQuery?</li>
<li>Installing the jQuery Library</li>
<li>The Document Ready function</li>
<li>.click() and .hide()</li>
<li>Understanding the Syntax</li>
<li>.toggle()</li>
<li>.slideToggle() and .find()</li>
<li>Animation Speed</li>
<li>.css(), this Selector and Basic Selector Filters</li>
<li>.hasClass(), .addClass(), .removeClass() and if Statements</li>
</ul>

Lots for the absolute beginner to get stuck into and see what the world of jQuery has to offer.]]></description>
			<content:encoded><![CDATA[<p>By now most web designers and developers have a very good understanding of jQuery and its capabilities; for most it is their go to JavaScript library when adding some additional functionality or interactivity to their web pages.</p>
<p>However there are still plenty of people out there who are new to web development and who would like to get started with this great language but don&#8217;t know how to.</p>
<p><em>Well, this one&#8217;s for you!</em></p>
<h2>What is jQuery?</h2>
<p>In essence, jQuery is a powerful JavaScript library which makes life a lot easier for those of us with little (or no) JavaScript knowledge. It allows us to add JavaScript functionality to a web page using much simpler code. jQuery is particularly apt at adding event-handling, transversing, animations or Ajax interactions to a web page.</p>
<p>I don&#8217;t know about you, but that all sounds rather confusing and boring&#8230; But believe me it&#8217;s not! And once you get a basic understanding of jQuery, you&#8217;ll be WOW-ing yourself in no time. And the best way to get this basic understanding is just to get started.</p>
<p><em>Are you ready?</em></p>
<h2>Installing the jQuery Library</h2>
<p>To make use of jQuery you first need to make the script available to your webpage. There are a few options available when adding the jQuery library to your webpage but they basically breakdown into two options:</p>
<ul>
<li>Downloading the latest source file and hosting it on your own website/server.</li>
<li>Linking to hosted files such as those on jQuery&#8217;s own site, on Google&#8217;s Libraries API or a few other hosted options.</li>
</ul>
<p>Personally I almost always opt for linking to files hosted on an external source unless for some reason I am developing without an internet connection, and that pretty much doesn&#8217;t happen to me anymore! So I am going to show you how to implement the hosted option. So break open your favourite text editor and let&#8217;s get started.</p>
<p>Let&#8217;s create the basic HTML page structure first:</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;jQuery 101 - Learning the Basics&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;!-- My page content will go here --&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>We are going to link to Google&#8217;s latest (at time of writing) stable copy of jQuery. A quick search of &#8220;google jquery&#8221; should find the page you are looking for but for reference purposes it is:</p>
<p><a title="Google Libraries API" href="https://developers.google.com/speed/libraries/devguide" target="_blank">https://developers.google.com/speed/libraries/devguide</a></p>
<p>Click on the jQuery (not jQuery UI) link in the table of contents. You are looking for the source path which references jquery.min.js. This is the compressed version of the file and will save you quite a bit of loading time &#8211; this is allows a good thing.</p>
<p>Now that we&#8217;ve got our reference, let&#8217;s add it to our page:</p>
<pre>...
&lt;head&gt;
    &lt;title&gt;jQuery 101 - Learning the Basics&lt;/title&gt;
    &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
...</pre>
<p><em>That&#8217;s it! How easy was that?</em></p>
<h2>Your First jQuery Function</h2>
<p>Now that the library is loaded onto our page, let&#8217;s prepare the page for our first jQuery function. Almost all jQuery code that you write will start with this function. It is the Document Ready function and basically it stops jQuery from running until the webpage has finished loading.</p>
<pre>...
&lt;head&gt;
    &lt;title&gt;jQuery 101 - Learning the Basics&lt;/title&gt;
    &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
        // This is a JavaScript comment
        // Load the Document Ready function
        $(document).ready(function(){
          // The rest of our jQuery will go in here
        });
    &lt;/script&gt;
&lt;/head&gt;
...</pre>
<p>Now that we have the boring bit done, let&#8217;s see what jQuery can do.</p>
<h2>Your Second jQuery Function</h2>
<p>Let&#8217;s create a paragraph with a link that hides the paragraph when clicked. Really very simple stuff with jQuery.</p>
<p>First let&#8217;s add the paragraph and link between the body tags:</p>
<pre>...
&lt;body&gt;
    &lt;p class="disappear"&gt;
        This paragraph will disappear when you click
        &lt;a href="#" class="make-disappear"&gt;this link&lt;/a&gt;.
    &lt;/p&gt;
&lt;/body&gt;
...</pre>
<p>Now let&#8217;s add our jQuery:</p>
<pre>...
$(document).ready(function(){
    $("a.make-disappear").click(function(){
        $("p.disappear").hide();
    });
});
...</pre>
<p>Save your code as a HTML document (such as index.html) and load the page in your favourite web browser (such as Google Chrome or Internet Explorer). Now click the link to see your script run by hiding the paragraph.</p>
<p><em>Amazing!</em></p>
<div class="view-tutorial-demo"><a title="jQuery 101 - Learning the Basics - Demo" href="http://creativeindividual.co.uk/wp-content/uploads/2012/jquery-101/">View the Tutorial Demo</a></div>
<h2>Understanding the Syntax</h2>
<p>Now that you have some code to look at, let&#8217;s try and understand what it&#8217;s doing by understanding the basic jQuery syntax. Every function in jQuery follows this basic structure, or syntax:</p>
<p>Basic Syntax:<strong> $(selector).action();</strong></p>
<p>Let&#8217;s break it down:</p>
<ul>
<li>The <strong>$</strong> (dollar sign) defines jQuery. Other JavaScript libraries also make use of this sign so if you are mixing libraries you can use <strong>jQuery</strong> instead.</li>
<li><strong>(selector)</strong> finds or queries elements in the HTML. So in our example the selector is <strong>(&#8220;a.make-disappear&#8221;)</strong> which tells jQuery to look for a hyperlink (a tag) with a class of make-disappear. The selector uses CSS syntax to query the DOM, such as .classname for classes and #idname for ids.</li>
<li><strong>.action()</strong> is the jQuery action to be performed on the HTML elements. So in our example the action is <strong>.click()</strong>, in other words when the user performs a click on the link. We then run another function within the .click() action.</li>
</ul>
<p>Our Syntax: <strong>$(selector).action(function(){$(selector).action();});</strong></p>
<ul>
<li>Within our .click() action we run another function by using <strong>function(){}</strong> and within this function we use <strong>$(selector).action();</strong> again.</li>
<li>Our second selector is <strong>(&#8220;p.disappear&#8221;)</strong> which tells us that when a link with the class of make-disappear is clicked, look for any paragraphs (p tag) with a class of disappear.</li>
<li>Our second action is <strong>.hide()</strong>. What this tells jQuery to do is that when a hyperlink with a class of make-disappear is clicked, look of any paragraphs with a class of disappear and hide them.</li>
</ul>
<h2>Some Basic Events</h2>
<p>Now that we have an understanding of our second jQuery function &#8211; making a paragraph disappear when we click a link &#8211; let&#8217;s look at some more basic events.</p>
<h3>.toggle()</h3>
<p>The .toggle() action combines the .hide() and .show() actions. Let&#8217;s create another link which toggles a span:</p>
<pre>...
&lt;body&gt;
    ...
    &lt;p class="toggle"&gt;
        &lt;a href="#"&gt;Show/Hide&lt;/a&gt;
        &lt;span&gt;This text will appear and disappear.&lt;/span&gt;
    &lt;/p&gt;
&lt;/body&gt;
...</pre>
<p>Now let&#8217;s add our jQuery:</p>
<pre>...
$(document).ready(function(){
    ...
    $("p.toggle a").click(function(){
        $("p.toggle span").toggle();
    });
});
...</pre>
<p>Save your file again and refresh your browser. By clicking the link you can show and hide the text wrapped in the span tag. <em>Magic!</em></p>
<div class="view-tutorial-demo"><a title="jQuery 101 - Learning the Basics - Demo" href="http://creativeindividual.co.uk/wp-content/uploads/2012/jquery-101/">View the Tutorial Demo</a></div>
<p>In the jQuery code above, instead of giving each element a class or id, I&#8217;ve only given the paragraph tag a class of toggle and then referenced other elements within the paragraph, just like you would with CSS. So by clicking the link within the paragraph with a class of toggle, we can show and hide the span within the paragraph.</p>
<p>All this is very nice, but we can do better than this! Introducing the .slideToggle() effect.</p>
<h3>.slideToggle() and .find()</h3>
<p>Now that you&#8217;ve gotten your head around some basics, lets speed things up a bit. In our next example we are going to look at .slideToggle() and .find(). As you probably have guessed .slideToggle() is very similar to .toggle() only with a slide animation effect. We are also introducing the .find() which helps us with the selector part of our query and could make our query up to <a title="Your jQuery: Now With 67% Less Suck" href="http://24ways.org/2011/your-jquery-now-with-less-suck" target="_blank">twice as fast</a>.</p>
<p>Let&#8217;s duplicate our previous code and instead of the paragraph having a class of toggle we&#8217;ll give it a class of slideToggle:</p>
<pre>...
&lt;body&gt;
    ...
    &lt;p class="slideToggle"&gt;
        &lt;a href="#"&gt;Show/Hide&lt;/a&gt;
        &lt;span&gt;This text will appear and disappear.&lt;/span&gt;
    &lt;/p&gt;
&lt;/body&gt;
...</pre>
<p>Now let&#8217;s add our jQuery:</p>
<pre>...
$(document).ready(function(){
    ...
    $("p.slideToggle").find("a").click(function(){
        $("p.slideToggle").find("span").slideToggle();
    });
});
...</pre>
<p>Save your file again and refresh your browser to see the .slideToggle() effect. <em>Pretty sweet!</em> But we can <strong>still</strong> do better than that!</p>
<div class="view-tutorial-demo"><a title="jQuery 101 - Learning the Basics - Demo" href="http://creativeindividual.co.uk/wp-content/uploads/2012/jquery-101/">View the Tutorial Demo</a></div>
<h3>Animation Speed</h3>
<p>A lot of actions, including .slideToggle, allow us to dictate the speed of the animation. There are a few options available:</p>
<ul>
<li>slow (600 milliseconds)</li>
<li>normal (400 milliseconds)</li>
<li>fast (200 milliseconds)</li>
<li>a custom speed in milliseconds</li>
</ul>
<p>Let&#8217;s update our jQuery by adding the fast speed:</p>
<pre>...
$(document).ready(function(){
    ...
    $("p.slideToggle").find("a").click(function(){
        $("p.slideToggle").find("span").slideToggle(<strong>"fast"</strong>);
    });
});
...</pre>
<p>Once again, save your file and refresh your browser.</p>
<p>Notice that we put the word fast in quotes in our code above. The same goes for normal and slow. However if we want to dictate our speed in milliseconds we just enter the number, like so:</p>
<pre>...
$(document).ready(function(){
    ...
    $("p.slideToggle").find("a").click(function(){
        $("p.slideToggle").find("span").slideToggle(<strong>1000</strong>);
    });
});
...</pre>
<p>Our .slideToggle() effect will now take 1 second (1000 milliseconds) to complete.</p>
<h3>.css(), this Selector and Basic Selector Filters</h3>
<p>Let&#8217;s push the boat out again with our jQuery. In our next example we are going to look at one new action, the this selector and some basic selector filters. The action is .css() and as you can imagine, this allows us to add or edit CSS properties to our DOM elements. The this selector allows us to target the element which has been actioned, such as through .click(). The basic selector filters we will be looking at are :even, :odd and :last, and these allow us to target even numbered elements, odd numbers elements and the last element in our given query.</p>
<p>In our next example we are going to create a checklist. That is, an unordered list with zebra strips and a function which allows us to click on a list item and change its colour plus put a line-through the text, showing that this item has been completed.</p>
<p>On a side note, this example is for the purposes of showing how something <strong>could</strong> be done and not how it <strong>should</strong> be done &#8211; we&#8217;ll get to that later.</p>
<p>OK, first let&#8217;s create our simple list:</p>
<pre>...
&lt;body&gt;
    ...
    &lt;ul class="list1"&gt;
        &lt;li&gt;List item 1&lt;/li&gt;
        &lt;li&gt;List item 2&lt;/li&gt;
        &lt;li&gt;List item 3&lt;/li&gt;
        &lt;li&gt;List item 4&lt;/li&gt;
        &lt;li&gt;List item 5&lt;/li&gt;
        &lt;li&gt;List item 6&lt;/li&gt;
    &lt;/ul&gt;
&lt;/body&gt;
...</pre>
<p>Now let&#8217;s style our list items using .css(). First let&#8217;s give each item some padding:</p>
<pre>...
$(document).ready(function(){
    ...
    $("ul.list1").find("li").css("padding","5px");
});
...</pre>
<p>Notice we are just running our usual selector with the .find() action and finally we are adding one CSS property to all the unordered lists-items &#8211; padding of 5 pixels on all sides.</p>
<p>Next let&#8217;s target all our even list items. Remember that arrays start with 0 so technically our first list item is even, not odd as you would expect. We&#8217;ll use the :even filter to do this:</p>
<pre>...
$(document).ready(function(){
    ...
    $("ul.list1").find("li").css("padding","5px");

   <strong> $("ul.list1").find("li:even").css({</strong>
       <strong> "border-top":"1px solid #eee",</strong>
       <strong> "background":"#fcfcfc"</strong>
   <strong> });</strong>
});
...</pre>
<p>Notice that this time our .css() action is a little different because we are specifying more than one CSS property. Make sure to remember this so that you don&#8217;t get tripped up in the future.</p>
<p>Now let&#8217;s style the other items in our list using the :odd selector filter:</p>
<pre>...
$(document).ready(function(){
    ...
    $("ul.list1").find("li").css("padding","5px");

    $("ul.list1").find("li:even").css({
        "border-top":"1px solid #eee",
        "background":"#fcfcfc"
    });

   <strong> $("ul.list1").find("li:odd").css({ </strong>
       <strong> "border-top":"1px solid #d3e9ff", </strong>
       <strong> "background":"#e8f3ff" </strong>
   <strong> }); </strong>});
...</pre>
<p>And finally let&#8217;s add another border at the bottom of the last list item using :last:</p>
<pre>...
$(document).ready(function(){
    ...
    $("ul.list1").find("li").css("padding","5px");

    $("ul.list1").find("li:even").css({
        "border-top":"1px solid #eee",
        "background":"#fcfcfc"
    });

    $("ul.list1").find("li:odd").css({
        "border-top":"1px solid #d3e9ff",
        "background":"#e8f3ff"
    });

    <strong>$("ul.list1").find("li:last").css("border-bottom","1px solid #d3e9ff"); </strong>
});
...</pre>
<p>If you save your document and refresh your browser you will see that we have created a very simple zebra strip effect.</p>
<p>Now let&#8217;s create our checklist functionality by using the <strong>this</strong> selector:</p>
<pre>...
$(document).ready(function(){
    ...
    $("ul.list1").find("li").css("padding","5px");

    $("ul.list1").find("li:even").css({
        "border-top":"1px solid #eee",
        "background":"#fcfcfc"
    });

    $("ul.list1").find("li:odd").css({
        "border-top":"1px solid #d3e9ff",
        "background":"#e8f3ff"
    });

    $("ul.list1").find("li:last").css("border-bottom","1px solid #d3e9ff");

    <strong>$("ul.list1").find("li").click(function(){</strong>
        <strong>$(this).css({</strong>
            <strong>"border-top":"1px solid #fcf47e",</strong>
            <strong>"background":"#ffffea",</strong>
            <strong>"text-decoration":"line-through"</strong>
        <strong>});</strong>
    <strong>});</strong>

});
...</pre>
<p>In this last query what we are asking jQuery to do is get any unordered lists with a class of list1 (ul.list1), find all the list items (li) within the unordered list, then, if any of the list items are clicked, apply the css following css styles <strong>only</strong> to the item that was clicked (this). Got it? Great, go check it out in your browser.</p>
<div class="view-tutorial-demo"><a title="jQuery 101 - Learning the Basics - Demo" href="http://creativeindividual.co.uk/wp-content/uploads/2012/jquery-101/">View the Tutorial Demo</a></div>
<h3>.hasClass(), .addClass(), .removeClass() and if Statements</h3>
<p>Remember how I said that the last example showed how a checklist function <strong>could</strong> be done but it wasn&#8217;t how it <strong>should</strong> be done? Well let&#8217;s learn how it should be done and while we are at it we&#8217;ll learn about .hasClass(), .addClass(), .removeClass() and JavaScript if statements, plus also add the functionality to unselect items too. <em>Exciting, eh?</em></p>
<p>OK, first duplicate the unordered list items from the previous example and give it a class of list2.</p>
<pre>...
&lt;body&gt;
    ...
    &lt;ul&gt;
        &lt;li&gt;List item 1&lt;/li&gt;
        &lt;li&gt;List item 2&lt;/li&gt;
        &lt;li&gt;List item 3&lt;/li&gt;
        &lt;li&gt;List item 4&lt;/li&gt;
        &lt;li&gt;List item 5&lt;/li&gt;
        &lt;li&gt;List item 6&lt;/li&gt;
    &lt;/ul&gt;
&lt;/body&gt;
...</pre>
<p>Easy so far. Next we are going to style our list using CSS rather than jQuery. So we need to create a stylesheet and link to it in our HTML head:</p>
<pre>...
&lt;head&gt;
    &lt;title&gt;jQuery 101 - Learning the Basics&lt;/title&gt;
    &lt;link rel="stylesheet" type="text/css" href="styles.css" /&gt;
    ...
&lt;/head&gt;
...</pre>
<p>OK, next add the following styles to your stylesheet. These will look very familiar to you as they are the same styles that we used in the last example. The only difference to note is that I&#8217;ve swapped around the styles for odd list items and even list items. Notice that we are using <a title="CSS3 Pseudo-classes: Harnessing the power!" href="http://creativeindividual.co.uk/2011/08/css3-pseudo-classes/">CSS3 Pseudo-classes</a>.</p>
<pre>ul.list2 li { padding: 5px; cursor: pointer; }
ul.list2 li:nth-of-type(odd) { border-top: 1px solid #eee; background: #fcfcfc; }
ul.list2 li:nth-of-type(even) { border-top: 1px solid #d3e9ff; background: #e8f3ff; }
ul.list2 li:last-of-type { border-bottom:1px solid #d3e9ff; }
ul.list2 li.completed { border-top: 1px solid #fcf47e; background: #ffffea; text-decoration: line-through; }</pre>
<p>We are almost done. Now just for our jQuery. We are going to run the same query as before. jQuery will find all the unordered lists with a class of list2, then will find all the list items within the unordered list. This time when the user clicks on a list item the jQuery will run an if statement. It will check if the list item has a class of completed by using .hasClass(), and if so will remove the class using .removeClass(). If it doesn&#8217;t has a class of completed it will add the class using .addClass().</p>
<pre>...
$(document).ready(function(){
    ...
    $("ul.list2").find("li").click(function(){
        if($(this).hasClass("completed")) {
            $(this).removeClass("completed");
        } else {
            $(this).addClass("completed");
        }
    });

});
...</pre>
<p>And that&#8217;s it. Go check it out in your browser.</p>
<div class="view-tutorial-demo"><a title="jQuery 101 - Learning the Basics - Demo" href="http://creativeindividual.co.uk/wp-content/uploads/2012/jquery-101/">View the Tutorial Demo</a></div>
<h2>Conclusion</h2>
<p>Hopefully by the time you&#8217;ve completed this tutorial you&#8217;ll have some good basics about jQuery and how to use it. This tutorial only scratches the surface and you&#8217;ve only just begun to delve into the exciting world of jQuery.</p>
<p>So &#8220;Where do I go from here?&#8221; I hear you ask. I&#8217;d recommend continuing your journey on the <a title="W3School jQuery" href="http://www.w3schools.com/jquery/default.asp" target="_blank">W3Schools jQuery tutorial</a> where you&#8217;ll cover what we&#8217;ve already learnt here, plus expand your knowledge even more by getting to grips with actions like .animate(), learning about callbacks, using Ajax and much more.</p>
<p>Not enough for you? Here&#8217;s some more useful resources:</p>
<ul>
<li><a title="jQuery Documentation" href="http://docs.jquery.com/" target="_blank">jQuery Documentation</a></li>
<li><a title="jQuery for Absolute Beginners Video Series" href="http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-video-series/" target="_blank">jQuery for Absolute Beginners Video Series</a></li>
<li><a title="24 Ways - Your jQuery: Now With 67% Less Suck" href="http://24ways.org/2011/your-jquery-now-with-less-suck">24 Ways &#8211; Your jQuery: Now With 67% Less Suck</a></li>
<li><a title="A Beginner’s Guide to jQuery" href="http://creativeindividual.co.uk/2010/10/a-beginners-guide-to-jquery/" target="_blank">A Beginner’s Guide to jQuery</a></li>
</ul>
<h2>Get The Source Code</h2>
<p>You can download the complete tutorial source code by clicking on the big button below and unzipping the file.</p>
<p><a href="http://creativeindividual.co.uk/wp-content/uploads/2012/jquery-101/jquery-101.zip"><img class="alignnone size-full wp-image-108" title="Download Source File - jQuery 101 - Learning the Basics" src="http://creativeindividual.co.uk/wp-content/uploads/2010/11/download-source-file.png" alt="Download Source File - jQuery 101 - Learning the Basics" width="648" height="104" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://creativeindividual.co.uk/2012/06/jquery-101-learning-the-basics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>5 jQuery Scripts &amp; Plugins You Can&#8217;t Live Without</title>
		<link>https://creativeindividual.co.uk/2011/10/5-jquery-scripts-plugins-you-cant-live-without/</link>
		<comments>https://creativeindividual.co.uk/2011/10/5-jquery-scripts-plugins-you-cant-live-without/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 18:38:51 +0000</pubDate>
		<dc:creator>Laura Montgomery</dc:creator>
				<category><![CDATA[5 You Can't Live Without]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://creativeindividual.co.uk/?p=250</guid>
		<description><![CDATA[<a href="/2011/10/5-jquery-scripts-plugins-you-cant-live-without" title="5 jQuery Scripts and Plugins You Can't Live Without"><img src="/wp-content/uploads/2010/10/jquery_banner.jpg" /></a>

This post introduces a new category of posts to the Creative Individual blog - <strong>5 You Can't Live Without</strong>. This is were I'll list my top 5  of a particular subject, such as Web Technologies, Sources of Online Inspiration, or as in the case of this post, <strong>5 jQuery Scripts &#038; Plugins You Can't Live Without</strong>.]]></description>
			<content:encoded><![CDATA[<p>This post introduces a new category of posts to the Creative Individual blog &#8211; <strong>5 You Can&#8217;t Live Without</strong>. This is were I&#8217;ll list my top 5  of a particular subject, such as Web Technologies, Sources of Online Inspiration, or as in the case of this post, <strong>5 jQuery Scripts &amp; Plugins You Can&#8217;t Live Without</strong>.</p>
<p>So, let&#8217;s find out which jQuery scripts and plugins have made my Top 5 list, and which one I consider to be number 1.</p>
<h2>5. jQuery UI</h2>
<p><a href="http://jqueryui.com/"><img class="alignnone size-full wp-image-253" title="jQuery UI" src="http://creativeindividual.co.uk/wp-content/uploads/2011/10/jquery_ui.png" alt="jQuery UI" width="648" height="407" /></a></p>
<blockquote><p><strong>jQuery UI</strong> provides abstractions for low-level interaction and animation, advanced effects and high-level, themeable widgets, built on top of the jQuery JavaScript Library, that you can use to build highly interactive web applications.</p></blockquote>
<p>I&#8217;ve included jQuery UI as a whole, rather than just a particular section of its functionality because I think its strength lies in the wide variety of functions this plugin provides. And also the ability to only add the script that you need to your project makes jQuery UI all the better.</p>
<p><strong>Website:</strong> <a href="http://jqueryui.com/">http://jqueryui.com/</a></p>
<h2>4. selectivizr</h2>
<p><a href="http://selectivizr.com/"><img class="alignnone size-full wp-image-256" title="selectivizr" src="http://creativeindividual.co.uk/wp-content/uploads/2011/10/selectivizr.png" alt="selectivizr" width="648" height="407" /></a></p>
<blockquote><p>selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8. Simply include the script in your pages and selectivizr will do the rest.</p></blockquote>
<p>I think selectivizr  has said it all; if you want to use CSS3 pseudo-classes in your web project and be confident that it&#8217;ll work across all browsers (ahem, in Internet Explorer 6-8), then selectivizr is a most! And let&#8217;s face it, why wouldn&#8217;t you use CSS3 pseudo-classes!</p>
<p><strong>Website:</strong> <a href="http://selectivizr.com/">http://selectivizr.com/</a></p>
<h2>3. Modernizr</h2>
<p><a href="http://www.modernizr.com/"><img class="alignnone size-full wp-image-254" title="Modernizr" src="http://creativeindividual.co.uk/wp-content/uploads/2011/10/modernizr.png" alt="Modernizr" width="648" height="407" /></a></p>
<blockquote><p><strong>Modernizr </strong>is an open-source JavaScript library that helps you build the next generation of HTML5 and CSS3-powered websites.</p></blockquote>
<p>Just like selectivizr, if you want to use the latest web technologies and be confident that everything is going to work as planned, then adding Modernizr will save you a lot of headaches. Add it too your default build files and don&#8217;t look back!</p>
<p><strong>Website:</strong> <a href="http://www.modernizr.com/">http://www.modernizr.com/</a></p>
<h2>2. Fancybox</h2>
<p><a href="http://fancybox.net/"><img class="alignnone size-full wp-image-252" title="Fancybox" src="http://creativeindividual.co.uk/wp-content/uploads/2011/10/fancybox.png" alt="Fancybox" width="648" height="407" /></a></p>
<blockquote><p>FancyBox is a tool for displaying images, html content and multi-media in a Mac-style &#8220;lightbox&#8221; that floats overtop of web page.</p></blockquote>
<p>There is a whole host of jQuery lightboxes out there but Fancybox is by far my favourite. It deals with different types of content wonderfully and manages to look great a the same time. The documentation is pretty good and there&#8217;s lots of examples to help you out too.</p>
<p><strong>Website:</strong> <a href="http://fancybox.net/">http://fancybox.net/</a></p>
<h2>1. Nivo Slider</h2>
<p><a href="http://nivo.dev7studios.com/"><img class="alignnone size-full wp-image-255" title="Nivo Slider" src="http://creativeindividual.co.uk/wp-content/uploads/2011/10/nivo-slider.png" alt="Nivo Slider" width="648" height="407" /></a></p>
<blockquote><p>The world&#8217;s most awesome jQuery Image Slider</p></blockquote>
<p>With a statement like that, you know its gotta be good! Just like Fancybox there are a lot of alternatives to Nivo Slider but Nivo Slider hasn&#8217;t made the top of my list for no reason. It is so easily to implement and comes with some highly polished themes and lots of options built in. And recently added are Nivo Slider Pro and a WordPress Plugin. If you haven&#8217;t already heard of this great image slider, go check it out now.</p>
<p><strong>Website:</strong> <a href="http://nivo.dev7studios.com/">http://nivo.dev7studios.com/</a></p>
<p><em>Do you agree with my Top 5 jQuery Scripts &amp; Plugins You Can&#8217;t Live Without? What plugins make your top 5 list? Share your thoughts below.</em></p>
]]></content:encoded>
			<wfw:commentRss>https://creativeindividual.co.uk/2011/10/5-jquery-scripts-plugins-you-cant-live-without/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Create Multiple Pop-up Divs using the jQuery prev() Method</title>
		<link>https://creativeindividual.co.uk/2011/08/create-multiple-pop-up-divs-using-the-jquery-prev-method/</link>
		<comments>https://creativeindividual.co.uk/2011/08/create-multiple-pop-up-divs-using-the-jquery-prev-method/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 16:19:46 +0000</pubDate>
		<dc:creator>Laura Montgomery</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://creativeindividual.co.uk/?p=240</guid>
		<description><![CDATA[<a href="/2011/08/create-multiple-pop-up-divs-using-the-jquery-prev-method" title="Create Multiple Pop-up Divs using the jQuery prev() Method"><img src="/wp-content/uploads/2011/08/banner.png" /></a>

This is an update on a previous post that showed you how to create a simple pop-up div using jQuery. The update shows you to recreate the same effect on multiple pop-up divs using the <strong>.prev() method</strong>, meaning you can avoid duplicating the code unnecessarily.

Included in the tutorial is a demo so that you can preview the script you will be learning to write, plus the source code for you to download and keep for future reference.]]></description>
			<content:encoded><![CDATA[<p>This tutorial is an update on a previous Creative Individual jQuery tutorial &#8211; <a title="Create a Pop-up div in jQuery" href="http://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/">Create a Pop-up div in jQuery</a>. The first tutorial showed you how to create a very simple pop-up div, but after a few requests in the comments, I felt it was important to update the technique so that multiple pop-up divs could be created without duplicating the code unnecessarily.</p>
<p>If you haven&#8217;t already read the first tutorial and are new to jQuery, it might be worth reading it to get a better understanding of the basic techniques before trying this slightly more advanced method.</p>
<h2>The Technique</h2>
<p>In this tutorial we are going to create a simple profile overview page containing 4 profile images and names. When we hover over the image or name a more detailed profile will appear. This div is positioned <strong>before</strong> the image and name link in the code and is initially hidden. When we hover over the image, a jQuery event will occur which will change the display declaration from hidden to block, making the div appear. This is when we make use of the <strong>prev()</strong> method.</p>
<h2>Tutorial Demo</h2>
<p>Still not sure what we are trying to achieve? Check out the tutorial demo below:</p>
<p><a title="Create Multiple Pop-up Divs using prev() method" href="http://creativeindividual.co.uk/wp-content/uploads/2011/jquery-popup-div-02/"><img class="alignnone size-full wp-image-243" title="Create Multiple Pop-up Divs using prev() method" src="http://creativeindividual.co.uk/wp-content/uploads/2011/08/preview.jpg" alt="" width="648" height="407" /></a></p>
<div class="view-tutorial-demo"><a title="Create Multiple Pop-up Divs using prev() method" href="http://creativeindividual.co.uk/wp-content/uploads/2011/jquery-popup-div-02/">View the Tutorial Demo</a></div>
<h2>The HTML</h2>
<p>Create a new HTML document and insert all the usual code – doctype, html tags, head tags, body tags, etc. as shown below:</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;title&gt;jQuery Tutorial - Pop-up div on hover - Version 2&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>With that done, let&#8217;s insert our mark-up. First we&#8217;ll create a <strong>div</strong> with an id of container to act as our content wrap (to center it on screen and give it a nice width). Then I&#8217;ve inserted some basic information for the viewer in the form of a <strong>h1</strong> and <strong>p</strong>. Very simple so far!</p>
<p>Then we get to the important bit. Create a <strong>div with a class of profile</strong>. It&#8217;s important to use a class because we are going to have more than one of these on screen and of course we want our code to validate. Inside this div create another <strong>div with a class of pop-up</strong>. Insert whatever kind of information you need here but for the purposes of this example, I&#8217;m going to use basic profile information &#8211; Name, Age, and Location.</p>
<p>Again inside our <span style="color: #000000;"><strong>div with a class of profile</strong> but below the <strong>div with a class of pop-up</strong>, add the trigger link. Inside my <strong>link with a class of trigger</strong> I&#8217;ve added an image and a span with the profile name.</span></p>
<pre>...
&lt;div id="container"&gt;
  &lt;h1&gt;jQuery Tutorial - Pop-up div on hover&lt;/h1&gt;
  &lt;p&gt;
    To view profile information for each person, simply hover your
    mouse cursor over the profile image or name.
  &lt;/p&gt;

  &lt;div class="profile"&gt;
    &lt;!-- Hidden on load by CSS --&gt;
    &lt;div class="pop-up"&gt;
      &lt;p&gt;
        &lt;strong&gt;Name:&lt;/strong&gt; Person 1&lt;br /&gt;
        &lt;strong&gt;Age:&lt;/strong&gt; 23&lt;br /&gt;
        &lt;strong&gt;Location:&lt;/strong&gt; Canada
      &lt;/p&gt;
    &lt;/div&gt;
    &lt;!-- Show the hidden div on hover --&gt;
    &lt;a href="#" title="Person 1" class="trigger"&gt;
      &lt;img src="blank-avatar.gif" alt="Profile Image" /&gt;
      &lt;br /&gt;
      &lt;span class="name"&gt;Person 1&lt;/span&gt;
    &lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;
...</pre>
<p>You then of course repeat the <strong>div with a class of profile</strong> however many times you need, but the basic structure remains the same.</p>
<p>Next we&#8217;ll need to create a div to clear the floats we will be adding to the profile divs in our css. I tend to always use a <strong>class of clear</strong> for this purpose. However you could add this style to almost anything, such as a <strong>footer</strong> or <strong>section</strong>.</p>
<pre>...
      &lt;!-- A clear div to sort out our floats --&gt;
      &lt;div class="clear"&gt;
        &lt;p&gt;
          This techique makes use of the &lt;strong&gt;prev()&lt;/strong&gt;
          method.
        &lt;/p&gt;
      &lt;/div&gt;

    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>There&#8217;s one last thing we need to do before we are finished with our HTML. Let&#8217;s link to our stylesheet which we will be creating in the next step.</p>
<pre>...
&lt;head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;title&gt;jQuery Tutorial - Pop-up div on hover - Version 2&lt;/title&gt;
  &lt;link rel="stylesheet" href="styles.css" type="text/css"
  media="screen" /&gt;
&lt;/head&gt;
...</pre>
<h2>The CSS</h2>
<p>Now its time to make things look a bit prettier. Create a new document and name it <strong>styles.css</strong>, i.e. the file name we have just linked to in our HTML.</p>
<p>First let&#8217;s quickly sort out our basic styles and wrapper div:</p>
<pre>body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #000 url(bg-texture.png) repeat;
  color: #dddddd;
}

h1, h3 {
  margin: 0;
  padding: 0;
  font-weight: normal;
}

a {
  color: #EB067B;
  text-decoration: none;
}

div#container {
  width: 580px;
  margin: 100px auto 0 auto;
  padding: 20px;
  background: #000;
  border: 1px solid #1a1a1a;
}</pre>
<p>All pretty basic stuff. Next we&#8217;ll style the profiles by floating them left and adding a width, plus giving our span a little bit of styling to make it sit nice.</p>
<pre>div.profile {
  width: 70px;
  text-align: center;
  float: left;
  margin: 10px 37px 30px 38px;
}

span.name {
  display: block;
  padding-top: 5px;
}</pre>
<p>Now the important bit, the pop-up div itself. We are going to use <span style="color: #000000;"><strong>position: absolute</strong> and <strong>display:none</strong>, plus a bit of styling to make it look good.</span></p>
<pre>/* HOVER STYLES */
div.pop-up {
  display: none;
  text-align: left;
  position: absolute;
  margin-top: -100px;
  width: 120px;
  padding: 0px 13px;
  background: #eeeeee;
  color: #000000;
  border: 1px solid #1a1a1a;
  font-size: 90%;
}</pre>
<p>And don&#8217;t forget our clearing div to sort our our floats on the profile divs.</p>
<pre>div.clear {
  clear: both;
}</pre>
<p>That&#8217;s the CSS done! Easy.</p>
<h2>The jQuery</h2>
<p>Now for what you&#8217;ve all be waiting for, the jQuery! Head back over to your HTML file. First we need to link to the jQuery library. I pretty much always link to Google&#8217;s files rather than download my own copy. The main reason for this is that it tends to speed things up a touch with user experience. Insert the following into the <strong>head</strong> of your HTML file.</p>
<pre>...
&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"&gt;&lt;/script&gt;
...</pre>
<p>Next we are going to create our pop-up effect. You can create your jQuery code in an external javascript file, such as <strong>popUp.js</strong> and linking to it just like we did above for the jQuery library. And in fact if you&#8217;re using a lot of javascript/jQuery I&#8217;d recommend it to keep things clean and legible. However for this example I&#8217;m going to write my code directly into the <strong>head</strong> of my HTML, below the line where I have link to Google&#8217;s jQuery library.</p>
<p><strong>Note:</strong> If your writing into the HTML head, you&#8217;ll need to wrap your jQuery with script tags:</p>
<pre>&lt;script type="text/javascript"&gt;
...
&lt;/script&gt;</pre>
<p>First let&#8217;s make our document ready. Below I&#8217;m using the long version for legibiliy but feel free to use the short version &#8211; <strong>$(function() { &#8230; });</strong></p>
<pre>$(document).ready(function() {
...
});</pre>
<p>If the javascript is running, i.e. the user doesn&#8217;t have javascript disabled or isn&#8217;t using a device that doesn&#8217;t support it, we can then use jQuery to change some CSS on our pop-up divs. First we&#8217;ll change the display declaration to <strong>display:block</strong>, then we&#8217;ll set an opacity declaration of <strong>opacity: 0</strong>:</p>
<pre>$(document).ready(function() {
  //If Javascript is running, change css on product-description to display:block
  //then hide the div, ready to animate
  $("div.pop-up").css({'display':'block','opacity':'0'})
});</pre>
<p>Next we are going to make use of the <strong>.hover()</strong> function, so that when someone hovers over our trigger, the image and span which are contained within the trigger link, something happens:</p>
<pre>...
$("a.trigger").hover()
...</pre>
<p>Inside this hover method we are going to create a function which will animate our pop-up divs, causing them to fade in. We&#8217;ll will use the <strong>this</strong> selector to select the current element and the <strong>.prev()</strong> method to select the previous element from the selector &#8211; in this case the current selector is <strong>a.trigger</strong> that we hovered over and the previous element is <strong>div.pop-up</strong> just before it in the code. We will then use <strong>.animate()</strong> to change the opacity from 0 to 1 and finally, set the animation speed. Sounds a lot but all this happens in only a few lines:</p>
<pre>...
$("a.trigger").hover(
  function () {
    $(this).prev().stop().animate({
      opacity: 1
    }, 500);
  }
)
...</pre>
<p>OK, so far so good. If you check your page in the browser you&#8217;ll see that our fade in effect is working perfectly. However, there is quite an obvious problem. The pop-up div doesn&#8217;t fade out again when we hover off. In fact it just hangs around there getting in the way! That&#8217;s because we haven&#8217;t told it to fade back out again when we hover off. Thankfully the .hover() function includes a <strong>callback</strong> which allows us to animate the hover off state. So let&#8217;s sort it out now.</p>
<p>We are going to do pretty much the same thing, only this time the opacity will change from 1 to 0 and we&#8217;ll speed up the animate a bit so that the pop-up fades out quicker than what it fades in:</p>
<pre>...
$("a.trigger").hover(
  function () {
    $(this).prev().stop().animate({
      opacity: 1
    }, 500);
  },
  function () {
    $(this).prev().stop().animate({
      opacity: 0
    }, 200);
  }
)
...</pre>
<p>Rechecking your page in the browser, you can now see that everything is going according to plan.</p>
<p><strong>That&#8217;s it!</strong></p>
<p><a title="Create Multiple Pop-up Divs using prev() method" href="http://creativeindividual.co.uk/wp-content/uploads/2011/jquery-popup-div-02/"><img class="alignnone size-full wp-image-243" title="Create Multiple Pop-up Divs using prev() method" src="http://creativeindividual.co.uk/wp-content/uploads/2011/08/preview.jpg" alt="" width="648" height="407" /></a></p>
<div class="view-tutorial-demo"><a title="Create Multiple Pop-up Divs using prev() method" href="http://creativeindividual.co.uk/wp-content/uploads/2011/jquery-popup-div-02/">View the Tutorial Demo</a></div>
<h2>Get The Source Code</h2>
<p>You can download the complete tutorial source code by clicking on the big button below and unzipping the file.</p>
<p><a href="/wp-content/uploads/2011/jquery-popup-div-02/jquery-popup-div-02.zip"><img class="alignnone size-full wp-image-108" title="Download Source File - jQuery Tutorial - Create Multiple Pop-up Divs using prev() method" src="http://creativeindividual.co.uk/wp-content/uploads/2010/11/download-source-file.png" alt="" width="648" height="104" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://creativeindividual.co.uk/2011/08/create-multiple-pop-up-divs-using-the-jquery-prev-method/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Create a Pop-up div in jQuery</title>
		<link>https://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/</link>
		<comments>https://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 22:57:17 +0000</pubDate>
		<dc:creator>Laura Montgomery</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://creativeindividual.co.uk/?p=190</guid>
		<description><![CDATA[<a href="/2011/02/create-a-pop-up-div-in-jquery" title="Create a Pop-up div in jQuery"><img src="/wp-content/uploads/2011/02/banner.png" /></a>

This is an easy tutorial suitable for those fairly new to jQuery. This tutorial will teach you how to create a simple pop-up effect, showing a hidden div, when you hover over the trigger link.

Included in the tutorial is a demo so that you can preview the script you will be learning to write, plus the source code for you to download and keep for future reference.

<div class="view-tutorial-demo"><strong>Update (13th August 2011):</strong> This technique has been updated to create the same effect with multiple pop-ups. View the new technique here:
<a title="Create Multiple Pop-up Divs using the jQuery prev() Method" href="/2011/08/create-multiple-pop-up-divs-using-the-jquery-prev-method/">Create Multiple Pop-up Divs using the jQuery prev() Method</a></div>]]></description>
			<content:encoded><![CDATA[<div class="view-tutorial-demo"><strong>Update (13th August 2011):</strong> This technique has been updated to create the same effect with multiple pop-ups. View the new technique here:<br />
<a title="Create Multiple Pop-up Divs using the jQuery prev() Method" href="/2011/08/create-multiple-pop-up-divs-using-the-jquery-prev-method/">Create Multiple Pop-up Divs using the jQuery prev() Method</a></div>
<p><a title="jQuery" href="http://jquery.com/">jQuery</a> is a powerful and easy-to-use Javascript library, like <a title="MooTools" href="http://mootools.net/">MooTools</a> and and <a title="Prototype" href="http://www.prototypejs.org/">Prototype</a>. It is not surprising that in recent years it has become extremely popular with website designers and has become the Javascript library of choice &#8211; <strong>I know it&#8217;s my favourite!</strong></p>
<p>If you are new to jQuery, you should check out my <a title="A Beginner's Guide to jQuery" href="http://creativeindividual.co.uk/2010/10/a-beginners-guide-to-jquery/">Beginner&#8217;s Guide to jQuery</a> article first, just to get to grips with the basics.</p>
<h2>Tutorial Demo</h2>
<p>This is an easy tutorial suitable for those fairly new to jQuery. This tutorial will teach you how to create a simple pop-up effect, showing a hidden div, when you hover over the trigger link.</p>
<p><a href="http://creativeindividual.co.uk/wp-content/uploads/2011/jquery-popup-div/"><img class="alignnone size-full wp-image-191" title="Demo Preview" src="http://creativeindividual.co.uk/wp-content/uploads/2011/02/preview.png" alt="" width="648" height="407" /></a></p>
<div class="view-tutorial-demo"><a title="View the Tutorial Demo - jQuery Tutorial - Pop-up div on hover" href="http://creativeindividual.co.uk/wp-content/uploads/2011/jquery-popup-div/">View the Tutorial Demo</a></div>
<h2>The HTML</h2>
<p>Create a new HTML document and insert all the usual code &#8211; doctype, html tags, head tags, body tags, etc. as shown below:</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;title&gt;jQuery Tutorial - Pop-up div on hover&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Notice how I am using the HTML5 doctype &#8211; <strong>&lt;!DOCTYPE html&gt;</strong> &#8211; it is a good idea to get into the habit of using this.</p>
<p>First we are going to create a <strong>div with an id of container</strong> to hold our page content and centralise it, just to make things a bit prettier. Inside this div we will add a <strong>h1, p</strong> (paragraph), and <strong>a </strong>(link/hyperlink) <strong>with an id of trigger</strong>. All this of course goes inside the <strong>body</strong> tags.</p>
<pre>...
&lt;body&gt;
  &lt;div id="container"&gt;
    &lt;h1&gt;jQuery Tutorial - Pop-up div on hover&lt;/h1&gt;
    &lt;p&gt;
      To show hidden div, simply hover your mouse over
      &lt;a href="#" id="trigger"&gt;this link&lt;/a&gt;.
    &lt;/p&gt;
  &lt;/div&gt;
&lt;/body&gt;
...</pre>
<p>Almost done with the HTML, the last thing we need to create is the div which will be hidden on the page loading, and triggered to become visible with the mouse hovers over the <strong>a#trigger tag</strong>.</p>
<pre>...
&lt;body&gt;
  &lt;div id="container"&gt;
    &lt;h1&gt;jQuery Tutorial - Pop-up div on hover&lt;/h1&gt;
    &lt;p&gt;
      To show hidden div, simply hover your mouse over
      &lt;a href="#" id="trigger"&gt;this link&lt;/a&gt;.
    &lt;/p&gt;

    &lt;!-- HIDDEN / POP-UP DIV --&gt;
    &lt;div id="pop-up"&gt;
      &lt;h3&gt;Pop-up div Successfully Displayed&lt;/h3&gt;
      &lt;p&gt;
        This div only appears when the trigger link is hovered over.
        Otherwise it is hidden from view.
      &lt;/p&gt;
    &lt;/div&gt;

  &lt;/div&gt;
&lt;/body&gt;
...</pre>
<h2>The CSS</h2>
<p>Now that we have our basic code in place, let&#8217;s style things up and make our page look a bit prettier. It is also at this stage that we will hide the pop-up div, using the <strong>display: none;</strong> css declaration.</p>
<p>Firstly, lets set some basic page styles and centre the container div, though if you are using this code within a website project, you don&#8217;t need to worry about this step as you will have your own page styles already set-up.</p>
<pre>body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #000 url(bg-texture.png) repeat;
  color: #dddddd;
}

h1, h3 {
  margin: 0;
  padding: 0;
  font-weight: normal;
}

a {
  color: #EB067B;
}

div#container {
  width: 580px;
  margin: 100px auto 0 auto;
  padding: 20px;
  background: #000;
  border: 1px solid #1a1a1a;
}</pre>
<p>For the sake of speed, I have added my styles inside the <strong>head</strong> tags of my html document, but for a live project I would always recommend attaching your styles to an external css document using the <strong>link</strong> tag.</p>
<p>In the css code above I am mostly just tweaking default browser styling, such as text colour, background colour, font-family, padding and margin &#8211; all pretty basic stuff. The most important bit is to make sure your <strong>div#container</strong> has a width and that the horizontal margins are set to auto &#8211; this centres the div, but again, pretty basic stuff.</p>
<p>Lastly, we are going to style the pop-up <strong>div</strong>. This is were the <strong>display: none;</strong> css attribute previously mentioned comes into play. It hides the div when the page loads. We also need to use <strong>position: absolute;</strong> so that the div gets positioned correctly with the jQuery we will add next. Again, we will add some basic styling such as width, colour, and padding, just to finish things off.</p>
<pre>/* HOVER STYLES */
div#pop-up {
  display: none;
  position: absolute;
  width: 280px;
  padding: 10px;
  background: #eeeeee;
  color: #000000;
  border: 1px solid #1a1a1a;
  font-size: 90%;
}</pre>
<h2>The jQuery</h2>
<p>Now we get to the exciting bit! Let&#8217;s add the jQuery to the page and get the pop-up div hover effect working. First we need to link to the jQuery library. You can download the latest files from <a title="jQuery.com" href="http://jquery.com/">jQuery.com</a> and link to them locally, but I prefer to link to Google&#8217;s library files for my own ease and for speed on the part of any visitors to your site. Insert the following line of code inside the <strong>head</strong> tags of your html document:</p>
<pre>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"&gt;&lt;/script&gt;</pre>
<p>Note that it is always worth checking what the latest version is and developing with that. However, this script definitely works with jQuery version 1.5.0.</p>
<p>Now let&#8217;s write our basic function. Just like with the css, I would always recommend linking to an external Javascript document, but for the sake of speed I have added my code into the <strong>head</strong> of my html document.</p>
<p>First let&#8217;s create a function:</p>
<pre>$(function() {

});</pre>
<p>Inside this function we are going to tell the browser that when someone hovers over the <strong>a tag</strong> with an <strong>id of trigger</strong>, to show the <strong>div</strong> with an <strong>id of pop-up</strong>.</p>
<pre>$(function() {
  $('a#trigger').hover(function() {
    $('div#pop-up').show();
  });
});</pre>
<p>Testing your page at this stage, you should see the div appear when you hover over the trigger link. However the first issue we have is that it doesn&#8217;t disappear again when you hover off the link. Let&#8217;s fix that.</p>
<p>By default, the .hover() method has a hover off call back. Add the following code to deal with the hover off method:</p>
<pre>$(function() {
  $('a#trigger').hover(function() {
    $('div#pop-up').show();
  }, function() {
    $('div#pop-up').hide();
  });
});</pre>
<p>We now have the hover off method set to hide the <strong>div#pop-up</strong> &#8211; great! Now notice when you test this page that the pop-up div appears no where near our mouse pointer. On this small page that is not an issue, but on a longer, busy page this could be a real problem &#8211; besides, it looks untidy!</p>
<p>Let&#8217;s make the pop-up div appear at our mouse-pointer. First add an <strong>e</strong> inside the brackets at <strong>.hover(function() {</strong>, then add the <strong>.css</strong> method after <strong>.show()</strong> but <em>before</em> the semi-colon.</p>
<pre>$(function() {
  $('a#trigger').hover(function(e) {
    $('div#pop-up').show()
      .css('top', e.pageY)
      .css('left', e.pageX)
      .appendTo('body');
  }, function() {
    $('div#pop-up').hide();
  });
});</pre>
<p>If you test your script at this stage, you will probably see the div flash and flicker as it appears and disappears from view. This is happening because the div is appearing right beneath our mouse-pointer. We need to move the div away slightly to deal with this. First create two variables to hold our values:</p>
<pre>$(function() {
  var moveLeft = 20;
  var moveDown = 10;
  ...
});</pre>
<p>Then add these variables to the <strong>e.pageX</strong> and <strong>e.pageY</strong>:</p>
<pre>$(function() {
  var moveLeft = 20;
  var moveDown = 10;

  $('a#trigger').hover(function(e) {
    $('div#pop-up').show()
      .css('top', e.pageY + moveDown)
      .css('left', e.pageX + moveLeft)
      .appendTo('body');
  }, function() {
    $('div#pop-up').hide();
  });
});</pre>
<p>When you re-test your page this time, things should look and behave much better. The div should pop-up when hovering over the trigger link, appearing 20px to the left and 10px below your mouse pointer. And it should disappear again when you hover off the trigger link.</p>
<p>We are pretty much there &#8211; however the div is pretty static once it appears on screen. Let&#8217;s make it follow our mouse pointer and give our script the extra WOW factor!</p>
<p>We are going to use the <strong>.mousemove</strong> method on the <strong>a#trigger</strong> selector and tell the <strong>div#pop-up</strong> to follow our mouse pointer using the same <strong>.css</strong> methods as before:</p>
<pre>$(function() {
  var moveLeft = 20;
  var moveDown = 10;

  $('a#trigger').hover(function(e) {
    $('div#pop-up').show()
      .css('top', e.pageY + moveDown)
      .css('left', e.pageX + moveLeft)
      .appendTo('body');
  }, function() {
    $('div#pop-up').hide();
  });

  $('a#trigger').mousemove(function(e) {
    $("div#pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
  });

});</pre>
<p>At this stage you can remove the first set of <strong>.css()</strong> methods as they are no longer needed. However, to make the code easier to read, I have just commented out the 3 now unnecessarily lines and added the semi-colon in after <strong>.show()</strong>. The code below is the final jQuery script:</p>
<pre>$(function() {
  var moveLeft = 20;
  var moveDown = 10;

  $('a#trigger').hover(function(e) {
    $('div#pop-up').show();
      //.css('top', e.pageY + moveDown)
      //.css('left', e.pageX + moveLeft)
      //.appendTo('body');
  }, function() {
    $('div#pop-up').hide();
  });

  $('a#trigger').mousemove(function(e) {
    $("div#pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
  });

});</pre>
<p><a href="http://creativeindividual.co.uk/wp-content/uploads/2011/jquery-popup-div/"><img class="alignnone size-full wp-image-191" title="Demo Preview" src="http://creativeindividual.co.uk/wp-content/uploads/2011/02/preview.png" alt="" width="648" height="407" /></a></p>
<div class="view-tutorial-demo"><a title="View the Tutorial Demo - jQuery Tutorial - Pop-up div on hover" href="http://creativeindividual.co.uk/wp-content/uploads/2011/jquery-popup-div/">View the Tutorial Demo</a></div>
<h2>Get The Source Code</h2>
<p>You can download the complete tutorial source code by clicking on the big button below and unzipping the file.</p>
<p><a href="/wp-content/uploads/2011/jquery-popup-div/jquery-popup-div.zip"><img class="alignnone size-full wp-image-108" title="Download Source File - jQuery Tutorial - Pop-up div on hover" src="http://creativeindividual.co.uk/wp-content/uploads/2010/11/download-source-file.png" alt="" width="648" height="104" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/feed/</wfw:commentRss>
		<slash:comments>95</slash:comments>
		</item>
		<item>
		<title>A Beginner&#8217;s Guide to jQuery</title>
		<link>https://creativeindividual.co.uk/2010/10/a-beginners-guide-to-jquery/</link>
		<comments>https://creativeindividual.co.uk/2010/10/a-beginners-guide-to-jquery/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 22:25:19 +0000</pubDate>
		<dc:creator>Laura Montgomery</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://creativeindividual.co.uk/?p=45</guid>
		<description><![CDATA[<a href="/2010/10/a-beginners-guide-to-jquery" title="A Beginner's Guide to jQuery"><img src="/wp-content/uploads/2010/10/jquery_banner.jpg" /></a>

Are you new to jQuery? Then check out the Creative Individual Beginner's Guide to jQuery and start learning the basics of this fantastic and powerful JavaScript library now. This jQuery Beginner's Guide includes links to jQuery Resources and Documentation, Tutorials and Ready-to-use Examples, a fantastic Cheat Sheet for jQuery 1.4.2, and information on linking to the Google and Microsoft hosted jQuery libraries.

This beginner's guide gives you everything you need to get started on becoming a proficient jQuery user and developer. What more could you ask for!]]></description>
			<content:encoded><![CDATA[<p>If you have been designing and developing for the web for more than a few months, it is very likely that you have already come across jQuery and understand how powerful a tool it can be. However if you are new to web design, particularly with regards to front-end development, then you just might want to take a closer look at this fantastic JavaScript library.</p>
<h2>What is jQuery?</h2>
<p>The first thing you may want to know is &#8216;What exactly is jQuery?&#8217; Well, jQuery is a powerful JavaScript library which simplifies programming with JavaScript. This is what <a title="jQuery" href="http://jquery.com/">jquery.com</a> has to say about itself:</p>
<blockquote><p>jQuery is a fast and concise JavaScript Library that simplifies HTML  document traversing, event handling, animating, and Ajax interactions  for rapid web development. <strong>jQuery is designed to change the way that you write JavaScript.</strong></p></blockquote>
<p>What is great about jQuery is that it is very easy to get to grips with, so you can be sure that you&#8217;ll hit the ground running with this powerful JavaScript library that packs quite a punch!</p>
<h2>Background Knowledge</h2>
<p>Before you get started with jQuery, it is a good idea to have a basic understanding of website coding. You should be able to write and understand:</p>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript<span style="font-style: italic; color: #777777;"> &#8211; Not essential but will certainly give you an advantage!</span></li>
</ul>
<p>If you are unfamiliar with any of these, I suggest looking at the <a title="W3Schools" href="http://www.w3schools.com/">W3Schools</a> website for more information. Their resources explain everything very clearly and provide great working examples.</p>
<p>Once you have got to grips with the basics of HTML, CSS and JavaScript, it is time to look at jQuery. Below I have compiled a list of resources and useful tutorials aimed at jQuery beginners.</p>
<h2>jQuery Resources</h2>
<p>Currently jQuery is all the rage and there is no shortage of great resources on-line. Below I have included a few which I feel those new to jQuery should be aware of.</p>
<h3>jQuery: Write Less, Do More</h3>
<p><a href="http://jquery.com/"><img class="alignnone size-full wp-image-46" title="jQuery" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/jquery.jpg" alt="" width="648" height="407" /></a></p>
<p>Let&#8217;s start with <a title="jQuery" href="http://jquery.com/">jQuery.com</a> &#8211; here you can download the full version of jQuery, including previous versions. There is lots of information and documentation to keep you on the right track. Plus there are tutorials and plenty of ready-to-use User Interface (UI) widgets and effects provided.</p>
<p><strong>Website:</strong> <a title="jQuery" href="http://jquery.com/">http://jquery.com/</a></p>
<h3>jQuery UI: User Interface</h3>
<p><a href="http://jqueryui.com/"><img class="alignnone size-full wp-image-49" title="jQuery UI: User Interface" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/jqueryui.jpg" alt="" width="648" height="407" /></a></p>
<p>And here is were you can download those great ready-to-use widgets and effects to bring your User Interface to life.</p>
<p><strong>Website:</strong> <a title="jQuery UI" href="http://jqueryui.com/">http://jqueryui.com/</a></p>
<h3>W3Schools: jQuery Tutorial</h3>
<p><a href="http://www.w3schools.com/jquery/default.asp"><img class="alignnone size-full wp-image-47" title="W3Schools - jQuery Tutorial" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/w3schools.jpg" alt="" width="648" height="407" /></a></p>
<p>I have already mentioned W3Schools in this post, but I truly can not emphasize how well this website explains everything. Plus the working examples are a great way to help you understand the code and tweak it to create your own effects.</p>
<p><strong>Website:</strong> <a title="W3Schools" href="http://www.w3schools.com/jquery/default.asp">http://www.w3schools.com/jquery/default.asp</a></p>
<h3>jQuery Visual Cheat Sheet 1.4.2</h3>
<p><a href="http://woorkup.com/wp-content/uploads/2010/06/jQuery-Visual-Cheat-Sheet-1.4.2.pdf"><img class="alignnone size-full wp-image-50" title="jQuery 1.4.2 Cheat Sheet" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/jquery_142_cheatsheet.jpg" alt="" width="648" height="407" /></a></p>
<p>At the time of this post going live, the latest stable version of jQuery is 1.4.2 &#8211; so if you happen to be using jQuery 1.4.2 this cheat sheet is a great visual aid to help you remember all the different attributes, effects, animations and much more!</p>
<p><strong>Website:</strong> <a title="jQuery Visual Cheat Sheet 1.4.2" href="http://woorkup.com/wp-content/uploads/2010/06/jQuery-Visual-Cheat-Sheet-1.4.2.pdf">http://woorkup.com/wp-content/uploads/2010/06/jQuery-Visual-Cheat-Sheet-1.4.2.pdf</a></p>
<h2>Tutorials &amp; Examples</h2>
<p>There are plenty of jQuery tutorials and examples on-line, including lots of ready-to-use effects and widgets. Below are some examples that I believe will help a beginner to jQuery quickly create some stunning effects which will really add the &#8216;wow&#8217; factor to any website project.</p>
<h3>FancyBox: An Alternative jQuery Lightbox</h3>
<p><a href="http://fancybox.net/"><img class="alignnone size-full wp-image-51" title="Fancybox" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/fancybox.jpg" alt="" width="648" height="407" /></a></p>
<p>I would be surprised if you have not come across FancyBox in use while surfing the internet. This jQuery script is a great way to show a gallery of images, both as thumbnails and as larger images, in a clean and simple manner. FancyBox also allows you to add captions and previous and next navigation to the &#8216;floating lightbox&#8217; style image. I truly recommend visiting the website to see this script in action!</p>
<p><strong>Website: </strong><a title="FancyBox" href="http://fancybox.net/">http://fancybox.net/</a></p>
<h3>Line25: Basic Beginners Guide to Installing a jQuery Lightbox</h3>
<p><a href="http://line25.com/tutorials/basic-beginners-guide-to-installing-a-jquery-lightbox"><img class="alignnone size-full wp-image-52" title="Line25: Basic Beginners Guide to Installing a jQuery Lightbox" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/line25.jpg" alt="" width="648" height="407" /></a></p>
<p>In this step-by-step tutorial on Line25, Chris Spooner shows you, from start to finish, how to had a jQuery lightbox script to your website gallery. In his tutorial, Chris recommends using the lightbox script from <a title="Leandro Vieira - Projects - jQuery Lightbox" href="http://leandrovieira.com/projects/jquery/lightbox/">http://leandrovieira.com/projects/jquery/lightbox/</a>.</p>
<p><strong>Website:</strong> <a title="Line25: Basic Beginners Guide to Installing A jQuery Lightbox" href="http://line25.com/tutorials/basic-beginners-guide-to-installing-a-jquery-lightbox">http://line25.com/tutorials/basic-beginners-guide-to-installing-a-jquery-lightbox</a></p>
<h3>ThemeForest: jQuery for Absolute Beginners Video Series</h3>
<p><a href="http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-video-series/"><img class="alignnone size-full wp-image-53" title="ThemeForest: jQuery for Absolute Beginners Video Series" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/themeforest_jquery_videos.jpg" alt="" width="648" height="407" /></a></p>
<p>If you are the type who prefers to watch video tutorials, then this series from ThemeForest, Lost in the Woods is just the thing you are looking for. This video series is aimed at absolute beginners to jQuery and takes you through everything from downloading the script from jQuery.com, to more advanced techniques such as jQuery&#8217;s Ajax capabilities and submitting information to a database.</p>
<p><strong>Website:</strong> <a title="ThemeForest: jQuery for Absolute Beginners Video Series" href="http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-video-series/">http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-video-series/</a></p>
<h2>jQuery For Designers: Coda Slider Effect</h2>
<p><a href="http://jqueryfordesigners.com/coda-slider-effect/"><img class="alignnone size-full wp-image-54" title="jQuery For Designers: Coda Slider Effect" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/coda_slider_effect.jpg" alt="" width="648" height="407" /></a></p>
<p>This great script from jQuery For Designers gives you a neat away to display lots of information on a website without using a lot of visual space &#8211; a great way to keep information above the &#8216;fold&#8217;. Don&#8217;t forget to check out the other tutorials on the site while you&#8217;re there!</p>
<p><strong>Website: </strong><a title="jQuery For Designers: Coda Slider Effect" href="http://jqueryfordesigners.com/coda-slider-effect/">http://jqueryfordesigners.com/coda-slider-effect/</a></p>
<h3>CSS Globe: Easy Slider 1.7</h3>
<p><a href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider"><img class="alignnone size-full wp-image-55" title="CSS Globe: Easy Slide 1.7" src="http://creativeindividual.co.uk/wp-content/uploads/2010/10/easy_slider.jpg" alt="" width="648" height="407" /></a></p>
<p>This script is quite similar to the Coda Slider Effect script above, however this script also includes an auto-play functionality so that the animation starts as soon as the page has finished loading.</p>
<p><strong>Website:</strong> <a title="CSS Globe: Easy Slider 1.7" href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider">http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider</a></p>
<h2>One More Thing</h2>
<p>In many of the examples I have provided above you are shown how to download the latest version of jQuery and link to it in your HTML file. However you can also use the hosted jQuery libraries from Google or Microsoft:</p>
<h3>Google jQuery Library</h3>
<blockquote><p><code>&lt;head&gt;<br />
&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;<br />
&lt;/head&gt;</code></p></blockquote>
<h3>Microsoft jQuery Library</h3>
<blockquote><p><code>&lt;head&gt;<br />
&lt;script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"&gt;&lt;/script&gt;<br />
&lt;/head&gt;</code></p></blockquote>
<h2>Closing Thoughts</h2>
<p>Once you have gone through and understood the resources above, you will be well-on-your-way to becoming a proficient jQuery user; with the ability to edit existing code to suit your needs or write your own code from scratch.</p>
<p>Are you new to jQuery? What are your thoughts regarding the resources provided above? Or have you used jQuery before? Can you recommend tutorials, examples and resources that will be of great help to others?</p>
]]></content:encoded>
			<wfw:commentRss>https://creativeindividual.co.uk/2010/10/a-beginners-guide-to-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
