Find index of selected option

Given this HTML…

      <option>Index zero</option>
      <option>Index one</option>
      <option>Index two</option>
  <p>Selected option has index: <span id="output">0</span></p>

here is a jQuery code snippet to find the index of the option that has been selected.

$('select').change(function() {
    var $this = $(this);
    $this.children().index( $this.children(':selected') )

Use jQuery's index function to return the index of the item that matches the ':selected' selector within the children of the select element.


Pipe to filter the Google Code Issue Updates feed

Google Code provides various feeds for every project they host. The "Issue Updates" feed contains entries for all the issues on the project. What if you're only interested in one issue? Filter the feed with Yahoo! Pipes of course.

My pipe is an example of how easily this can be achieved with a simple regex in the Filter module. I've tied the name of the project and the issue number to user inputs, so you can use this pipe to track your favourite issue on your pet project. Personally, I'm looking forward to having support for Pie Charts baked into an official release of flot, and will be tracking progress with this feed.

Browser support for built-in Ajax Libraries

When Google launched the Ajax Libraries API in May, Dion Almaer noted that it might be possible for browsers to further improve performance of applications using this API:

If we see good usage, we can work with browser vendors to automatically ship these libraries. Then, if they see the URLs that we use, they could auto load the libraries, even special JIT'd ones, from their local system. Thus, no network hit at all!

A great idea, but as far as I know not one that any browser has currently taken up. When Google announced Chrome in September I wondered if they might be the first browser to support such a feature. Today I finally got around to testing the latest Chrome using Wireshark and discovered that it doesn't yet do this, at least not for the latest jQuery release.

So I've taken affirmative action in the spirit of John Resig's recent advice and filed a feature request at the Google Chrome support site.