Highlighting keywords from a search can be done on the server-side, by using your development languages string replace functions, but this can add complexity to…
Labels activate checkboxes / radio buttons with jQuery
The small jQuery snippet below will make those plain old labels that follow checkboxes and radio buttons active. That is, they will activate/deactivate the checkboxes…
JavaScript Date object – 0 offset Month
I find the Javascript Date constructor to be a little non-intuitive, primarily because the Month is 0 offset, but the day is not. The script…
Labelling form fields without using labels – Method II
Here's a handy method I came up with to "move" labels inside form fields, to save real estate. It also degrades gracefully if the user…
Vertically center a div with jQuery
$('.vcenter').each(function() { $(this).css('margin-top', (parseInt($(this).parent().css('height')) – parseInt($(this).css('height'))) / 2); });
AJAX calls being cached
I spent a couple hours this morning trying to figure out why Internet Explorer was return the same result from an AJAX request which returns…
JavaScript For loop vs. jQuery $.each function
Comparing jQuery each function vs. javascript for loop for iterating through a large array. We're assuming that the jQuery method would be measurably slower, as…
Focus on first empty field
It's a common practice on many sites to put the focus on the first input. But, in many cases, this first input has already been…
Forcing external links to open in a new window with Javascript
This task becomes relatively easy with the help of our friend jQuery. The code below is almost too simple! $('a').each(function() { url = $(this).attr('href');…
Table background on alternate rows
3 ways to do this: jQuery #1 $('table tr:even').addClass('even'); jQuery #2 $('table tr:even').css('background-color', '#eee'); Background Image If you are certain that all table rows will…