Posts Tagged ‘jQuery’

Using JQuery to find the Selected Index of a Select Element

Thursday, May 7th, 2009

This was palmToFace obvious once it occoured to me but due to the lack of Google results on the topic:


$("select#idOfElement").attr("selectedIndex")

Update, even better!


//see Dan's comment
$("#idOfElement").attr("selectedIndex")

Make JQuery Go Faster!

Tuesday, April 28th, 2009

A nice article on improving your jquery codez:

http://www.artzstudio.com/2009/04/jquery-performance-rules/

JQuery and Building HTML Elements Fast

Monday, April 13th, 2009

A co-worker recently shared an article by Josh Powell about how to use the jquery append() function much more efficiently.  Thank goodness because today my JS requirements changed and I now had to build some html on keypress instead of onchange.  The codez I was using was way too slow for this sort of mischief.

My take on the article is thus:  Don’t create and append nested elements to nested elements to nested elements into your document.  Instead build the HTML in a string and then append just one time.  The article explains it quite well so I won’t rehash the whole thing.  Check it out:

http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly

I file that one under “stuff I didn’t know I needed to know until days after I learned it”.