Tip: getting values from an options list

So, if you’ve ever converted an options list into a single array of values you might have intuitively done this: var select = $(‘#mySelectElement’)[0]; var values = new Array(); for (var i=0; i < select.length; i++) { values.push(select.options[i].value); } Pretty boring aye? There is a snazzier (is that a word?) alternative, which is to use […]

jQuery: Shuffle Plugin

I recently came across a really compact array shuffling function on JSFromHell.com, which I thought would make a nifty jQuery plugin. This jQuery shuffle plugin could be applied to any HTML element or Array object. (function($){ $.fn.shuffle = function() { return this.each(function(){ var items = $(this).children(); return (items.length) ? $(this).html($.shuffle(items)) : this; }); } $.shuffle […]