JQuery function to absolutely position elements in a table cell

While table cells in HTML may look like block elements, they’re not, and thus you can’t absolutely position things inside them. I’ve been using a script that I’ve had for ages to get around this. The script would add a helper div around the contents of every cell that was relatively positioned. The benefit of …

Add a class to the first and last items of a WordPress menu

If you’re using the WordPress dynamic menus, you can use the following code to add first-menu-item and last-menu-item to the appropriate menu items. Add the following to your theme’s functions.php: function add_first_and_last($output) { $output = preg_replace(‘/class=”menu-item/’, ‘class=”first-menu-item menu-item’, $output, 1); $output = substr_replace($output, ‘class=”last-menu-item menu-item’, strripos($output, ‘class=”menu-item’), strlen(‘class=”menu-item’)); return $output; } add_filter(‘wp_nav_menu’, ‘add_first_and_last’); Via Kuroi …