<?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>Chris Tate-Davies &#187; HTML</title>
	<atom:link href="http://www.christatedavies.co.uk/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christatedavies.co.uk</link>
	<description>An archive of helpful tit bits of information for development, and probably some stuff that is incomplete, wrong or boring...</description>
	<lastBuildDate>Tue, 31 Jan 2012 11:18:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sorting a SELECT with JQuery</title>
		<link>http://www.christatedavies.co.uk/2010/10/04/sorting-a-select-with-jquery/</link>
		<comments>http://www.christatedavies.co.uk/2010/10/04/sorting-a-select-with-jquery/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 12:36:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=114</guid>
		<description><![CDATA[Just a simple function to sort an already populated list. Obviously it would be easier to sort before populating, but there are the odd occasion where this is more complicated than you thought. Requirements : JQuery var selectOptions = $("#selectId option"); Then, we just run the sort command on the options array &#8211; and this [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/10/04/sorting-a-select-with-jquery/' addthis:title='Sorting a SELECT with JQuery ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Just a simple function to sort an already populated list. Obviously it would be easier to sort before populating, but there are the odd occasion where this is more complicated than you thought.</p>
<p>Requirements : JQuery</p>
<pre>var selectOptions = $("#selectId option");</pre>
<p>Then, we just run the sort command on the options array &#8211; and this easily sorts the items.</p>
<pre>selectOptions.sort(function(a, b) {
    if (a.text &gt; b.text) {
        return 1;
    }
    else if (a.text &lt; b.text) {
        return -1;
    }
    else {
        return 0
    }
});</pre>
<p>Then, at the end empty the select object and re-append the sorted options array</p>
<pre>$("#selectId").empty().append(selectOptions);</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/10/04/sorting-a-select-with-jquery/' addthis:title='Sorting a SELECT with JQuery ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2010/10/04/sorting-a-select-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TabIndex in HTML</title>
		<link>http://www.christatedavies.co.uk/2010/03/18/tabindex-in-html/</link>
		<comments>http://www.christatedavies.co.uk/2010/03/18/tabindex-in-html/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 01:38:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[tabindex]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=9</guid>
		<description><![CDATA[TabIndex is an attribute to HTML elements that tells the browser which control takes focus next when TAB is pressed. &#60;input id="one" tabindex="3" /&#62; &#60;input id="two" tabindex="1" /&#62; &#60;input id="three" tabindex="2" /&#62; &#60;input id="four" tabindex="4" /&#62; Here, once the page is loaded, the first TAB press will set focus to input two, and then subsequent [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/03/18/tabindex-in-html/' addthis:title='TabIndex in HTML ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<h2><span style="line-height: 19px; font-size: 13px;">TabIndex is an attribute to HTML elements that tells the browser which control takes focus next when TAB is pressed.</span></h2>
<pre>&lt;input id="one" tabindex="3" /&gt;

&lt;input id="two" tabindex="1" /&gt;

&lt;input id="three" tabindex="2" /&gt;

&lt;input id="four" tabindex="4" /&gt;</pre>
<p>Here, once the page is loaded, the first TAB press will set focus to input two, and then subsequent presses will move the focus to three, one and then four &#8211; before returning to two.</p>
<p>In a static web page it can be useful, but in a dynamic page, then this is a truely awful way of moving around.Especially as a web browser will automatically give the controls their own order, naturally in the order that they appear in the HTML source.</p>
<p>So why use it? I have no idea. I have never needed this attribute, and cannot ever see me ever using it.</p>
<p>I&#8217;ve just had to remove all the wonky tabindex&#8217;s from a huge page. Luckily I use an IDE that lets me search and replace using regular expressions! <a title="Online Regular Expression Testing Tool" href="/htsrv/trackback.php?tb_id=32">Online Regular Expression Testing Tool</a></p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/03/18/tabindex-in-html/' addthis:title='TabIndex in HTML ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2010/03/18/tabindex-in-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

