jQuery: Append a CSS class to any item or last item

<script type="text/javascript">
	jQuery("p:last").addClass(" last");
</script>

It’s important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements.

More than one class may be added at a time, separated by a space, to the set of matched elements, like so:

$("p").addClass("myClass yourClass");

(more…)

Continue ReadingjQuery: Append a CSS class to any item or last item

Setting Equal Heights with jQuery

We wrote a script to “equalize” the heights of boxes within the same container and create a tidy grid — with little overhead.

Creating the visual effect of equal-height columns or content boxes has been a challenge ever since we abandoned table-based layouts. When developing complex web applications or site designs we’ve found that it often makes the most sense from a usability and performance standpoint to use a simple JavaScript workaround: our equalHeights() function determines the heights of all sibling elements in a container, and then sets each element’s minimum height to that of the tallest element. When JavaScript is disabled, the boxes or columns appear with varying heights, but the content remains legible and the page is still completely usable.
(more…)

Continue ReadingSetting Equal Heights with jQuery