<?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>Premiumbeat.com -Tech blog &#124; jQuery, HTML5, Flash and more.</title>
	<atom:link href="http://www.premiumbeat.com/tech-blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.premiumbeat.com/tech-blog</link>
	<description>Premiumbeat.com tech blog</description>
	<lastBuildDate>Thu, 22 Jul 2010 15:26:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to load css files with AJAX using jQuery</title>
		<link>http://www.premiumbeat.com/tech-blog/how-to-load-css-file-with-ajax-using-jquery/</link>
		<comments>http://www.premiumbeat.com/tech-blog/how-to-load-css-file-with-ajax-using-jquery/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 04:25:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[jQuery Tips]]></category>

		<guid isPermaLink="false">http://www.premiumbeat.com/tech-blog/?p=279</guid>
		<description><![CDATA[This week I was building a music player widget with jQuery and decided to make multiple skins available for people to choose from.
I figured I needed to dynamically load the css files with AJAX when the widget is initialized.
This is what I came up with:

&#60;script type=&#34;text/javascript&#34; charset=&#34;utf-8&#34;&#62;
$&#40;document&#41;.ready&#40;function&#40;&#41;&#123;
	$.ajax&#40;&#123;
		url:&#34;style.css&#34;,
		success:function&#40;data&#41;&#123;
			 $&#40;&#34;&#60;style&#62;&#60;/style&#62;&#34;&#41;.appendTo&#40;&#34;head&#34;&#41;.html&#40;data&#41;;
		&#125;
	&#125;&#41;
&#125;&#41;
&#60;/script&#62;

]]></description>
			<content:encoded><![CDATA[<p>This week I was building a music player widget with jQuery and decided to make multiple skins available for people to choose from.</p>
<p>I figured I needed to <strong>dynamically load the css files with AJAX</strong> when the widget is initialized.</p>
<p>This is what I came up with:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> charset<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;utf-8&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		url<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;style.css&quot;</span><span style="color: #339933;">,</span>
		success<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			 $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;style&gt;&lt;/style&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;head&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.premiumbeat.com/tech-blog/how-to-load-css-file-with-ajax-using-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery and checkboxes, the complete guide.</title>
		<link>http://www.premiumbeat.com/tech-blog/jquery-and-checkboxes-the-complete-guide/</link>
		<comments>http://www.premiumbeat.com/tech-blog/jquery-and-checkboxes-the-complete-guide/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 04:03:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery Tips]]></category>

		<guid isPermaLink="false">http://www.premiumbeat.com/tech-blog/?p=262</guid>
		<description><![CDATA[jQuery is a great framework but sometimes the jQuery.com documentation is not enough to answer all your questions. Here is a list of pretty much everything you can do with checkboxes.
Selecting / Unselecting a checkbox

// Check a checkbox
$&#40;'input[name=acheckbox]'&#41;.attr&#40;'checked', true&#41;;
&#160;
// Uncheck a checkbox
$&#40;'input[name=acheckbox]'&#41;.attr&#40;'checked', false&#41;;

Selecting / Unselecting all checkboxes

// This will select all checkboxes
$&#40;&#34;input:checkbox&#34;&#41;.attr&#40;'checked', true&#41;;
&#160;
// This will [...]]]></description>
			<content:encoded><![CDATA[<p>jQuery is a great framework but sometimes the jQuery.com documentation is not enough to answer all your questions. <br />Here is a list of pretty much everything you can do with checkboxes.</p>
<h3>Selecting / Unselecting a checkbox</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Check a checkbox</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=acheckbox]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Uncheck a checkbox</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=acheckbox]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Selecting / Unselecting all checkboxes</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// This will select all checkboxes</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input:checkbox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// This will unselect all checkboxes</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input:checkbox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Verifying if a checkbox is selected</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// this will return true is the checkbox is checked, if not it will return false.</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=acheckbox]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">':checked'</span><span style="color: #009900;">&#41;</span></pre></div></div>

<h3>Getting a list of selected checkboxes</h3>
<p>There are several ways to get  a list the of selected checkboxes, here is my take on it.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Extend jQuery with custom method</span>
jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">getCheckboxValues</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
    <span style="color: #003366; font-weight: bold;">var</span> values <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
    <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> 
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
        <span style="color: #006600; font-style: italic;">// push values into array</span>
        values<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #006600; font-style: italic;">// return array of selected checkboxes</span>
    <span style="color: #000066; font-weight: bold;">return</span> values<span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input:checked&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getCheckboxValues</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// this would alert an array containing the values of the selected checkboxes</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.premiumbeat.com/tech-blog/jquery-and-checkboxes-the-complete-guide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to make an HTML5 music player / Using the audio tag</title>
		<link>http://www.premiumbeat.com/tech-blog/how-to-make-an-html5-music-player-using-the-audio-tag/</link>
		<comments>http://www.premiumbeat.com/tech-blog/how-to-make-an-html5-music-player-using-the-audio-tag/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 04:10:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery Tips]]></category>

		<guid isPermaLink="false">http://www.premiumbeat.com/tech-blog/?p=196</guid>
		<description><![CDATA[There has been a lot of noise about HTML5 lately (thanks to Steve Jobs), but surprisingly few people actually know how and when to use HTML5 tags. Obviously one of the most talked about addition to HTML5 is the audio tag.
Here is a basic audio tag implementation:

&#60;audio id=&#34;player&#34; name=&#34;player&#34; src=&#34;song.mp3&#34; controls=&#34;controls&#34;&#62;
&#60;/audio&#62;

Simple and elegant right? Not [...]]]></description>
			<content:encoded><![CDATA[<p>There has been a lot of noise about HTML5 lately (thanks to Steve Jobs), but surprisingly few people actually know how and when to use HTML5 tags. Obviously one of the most talked about addition to HTML5 is the audio tag.</p>
<p>Here is a basic audio tag implementation:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>audio id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;player&quot;</span> <span style="color: #000066;">name</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;player&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;song.mp3&quot;</span> controls<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;controls&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>audio<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Simple and elegant right? Not really.</p>
<h3><strong>The Problem</strong></h3>
<p>Every browser has it&#8217;s own way of displaying the controls. If you look at the music player on safari, you&#8217;ll see a Quicktime player. If you look at it on Firefox, you&#8217;ll have a completely different look, same goes for other browsers including the iPad and iPhone.</p>
<h3><strong>The Solution</strong></h3>
<p>There is of course a solution to all this: <strong>Make your own controls.</strong></p>
<p>The audio tag, like any other html element, can be modified via javascript.<strong> </strong>In other words,  you can play, stop, pause and load<strong> </strong>audio files remotely with simple javascript methods.<strong> </strong></p>
<p>Below is a simple example of how to use Javascript ( jQuery in this case )<strong> </strong>to <strong>control music playback with an html5 audio tag</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#play-bt&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#audio-player&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Music started&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#pause-bt&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#audio-player&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">pause</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Music paused&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#stop-bt&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#audio-player&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">pause</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#audio-player&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">currentTime</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Music Stopped&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>audio id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;audio-player&quot;</span> <span style="color: #000066;">name</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;audio-player&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;song.mp3&quot;</span> <span style="color: #339933;">&gt;&lt;/</span>audio<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;message&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>a id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;play-bt&quot;</span> href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Play music<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;</span>a id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;pause-bt&quot;</span> href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Pause music<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;</span>a id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;stop-bt&quot;</span> href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Stop music<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></pre></div></div>

<p>
This is obviously a very basic implementation of HTML5 music player controls but you get the idea. </p>
<h3><strong>Important Notes / considerations</strong></h3>
<p>When deciding whether to use flash or HTML5 audio in your projects, always consider the following:</p>
<ul>
<li>Because of format licensing issues, you <strong>cannot play mp3 files in Opera and Firefox.</strong> In other words you will need to have all your audio files in both .ogg and .mp3 format in order for everyone to enjoy it.</li>
<li>HTML5 penetration rate is still very low and will take years to catch up to Flash.</li>
<li>As you probably know, Flash is not compatible on the iPhone / iPad / iPod, so HTML5 has the advantage here.</li>
</ul>
<p>More posts on HTML5 coming soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.premiumbeat.com/tech-blog/how-to-make-an-html5-music-player-using-the-audio-tag/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Selecting an object at a specific index with jQuery</title>
		<link>http://www.premiumbeat.com/tech-blog/selecting-an-object-at-a-specific-index-with-jquery-2/</link>
		<comments>http://www.premiumbeat.com/tech-blog/selecting-an-object-at-a-specific-index-with-jquery-2/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 03:56:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jQuery Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.premiumbeat.com/tech-blog/?p=185</guid>
		<description><![CDATA[As you probably know, the jQuery selector returns all the matched elements as an array. But what if you needed to select only the third element in the returned elements list?
The code below will return only the 3rd element in the returned selected list

// get 3rd item as a jQuery object:
$&#40;'div:eq(2)'&#41;
&#160;
// get 3rd item as [...]]]></description>
			<content:encoded><![CDATA[<p>As you probably know, the jQuery selector returns all the matched elements as an array. But what if you needed to select only the third element in the returned elements list?<br />
The code below will return only the 3rd element in the returned selected list</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// get 3rd item as a jQuery object:</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div:eq(2)'</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// get 3rd item as a pure DOM object</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.premiumbeat.com/tech-blog/selecting-an-object-at-a-specific-index-with-jquery-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to bind events in jQuery</title>
		<link>http://www.premiumbeat.com/tech-blog/how-to-bind-events-in-jquery/</link>
		<comments>http://www.premiumbeat.com/tech-blog/how-to-bind-events-in-jquery/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 03:47:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jQuery Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.premiumbeat.com/tech-blog/?p=179</guid>
		<description><![CDATA[I used to bind mouse events to dom elements using the .click() method like below:

$&#40;&#34;a.button&#34;&#41;.click&#40;function&#40;&#41;&#123;
	alert&#40;&#34;A button was clicked&#34;&#41;;
&#125;&#41;

The problem with this technique is that everytime a new button is added to the dom, you need to re-apply the click behavior to it.
Fortunately, jQuery introduced the .live() method in version 1.3 which solves that issue. The [...]]]></description>
			<content:encoded><![CDATA[<p>I used to bind mouse events to dom elements using the .click() method like below:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a.button&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;A button was clicked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>The problem with this technique is that everytime a new button is added to the dom, you need to re-apply the click behavior to it.</p>
<p>Fortunately, jQuery introduced the .live() method in version 1.3 which solves that issue. The .live() method will bind an event to any element matching the selector now or at any point in the future, so if you you add new buttons to the page dynamically, they will also be binded to the event.</p>
<p>Use:as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.button'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;A button was clicked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.premiumbeat.com/tech-blog/how-to-bind-events-in-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to remove or empty elements in jQuery</title>
		<link>http://www.premiumbeat.com/tech-blog/quick-jquery-tip-how-to-select-children-or-parent-elements-in-jquery/</link>
		<comments>http://www.premiumbeat.com/tech-blog/quick-jquery-tip-how-to-select-children-or-parent-elements-in-jquery/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 03:22:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jQuery Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.premiumbeat.com/tech-blog/?p=170</guid>
		<description><![CDATA[Removing or emptying dom elements with jQuery

// Removes the element from the dom
$&#40;'selector'&#41;.remove&#40;&#41;
&#160;
// Empties the element
$&#40;'selector'&#41;.empty&#40;&#41;;

Note that this will empty or remove every element matched by the selector, so if you have 25 divs with the class &#8220;article-content&#8221; and you do $(&#8217;div.article-content&#8217;).empty(); , It will empty the 25 divs selected.
]]></description>
			<content:encoded><![CDATA[<p>Removing or emptying dom elements with jQuery</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Removes the element from the dom</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selector'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Empties the element</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selector'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Note that this will empty or remove every element matched by the selector, so if you have 25 divs with the class &#8220;article-content&#8221; and you do $(&#8217;div.article-content&#8217;).empty(); , It will empty the 25 divs selected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.premiumbeat.com/tech-blog/quick-jquery-tip-how-to-select-children-or-parent-elements-in-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to select children or parent elements in jQuery</title>
		<link>http://www.premiumbeat.com/tech-blog/how-to-select-children-and-parent-elements-with-jquery/</link>
		<comments>http://www.premiumbeat.com/tech-blog/how-to-select-children-and-parent-elements-with-jquery/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 03:09:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jQuery Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.premiumbeat.com/tech-blog/168/</guid>
		<description><![CDATA[Selecting Child or parent elements in jQuery is quite simple and powerful:

// Selecting child elements
$&#40;'selector'&#41;.children&#40;'.class-name'&#41;
&#160;
// or any other selector like:
$&#40;'selector'&#41;.children&#40;'div span'&#41;
&#160;
// Selecting the parent element
$&#40;'selector'&#41;.parent&#40;&#41;

]]></description>
			<content:encoded><![CDATA[<p>Selecting Child or parent elements in jQuery is quite simple and powerful:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Selecting child elements</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selector'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.class-name'</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// or any other selector like:</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selector'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div span'</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Selecting the parent element</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selector'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.premiumbeat.com/tech-blog/how-to-select-children-and-parent-elements-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

