Cross browser opacity with CSS

If you thought you couldn’t achieve cross browser opacity with pure CSS then you were wrong. Appart from the fact it doesn’t validate the following snippet works. Just be careful about the order you declare them in.

.makeTransparent{
opacity: .75; /* standard: ff gt 1.5, opera, safari */
-ms-filter: “alpha(opacity=75)”; /* ie 8 */
filter: alpha(opacity=75); /* ie lt 7 */
-khtml-opacity: .75; /* safari 1.x */
-moz-opacity: .75; /* ff lt 1.5, netscape */
}

jQuery selectors – not first – not:(:first)

Selectors are the building blocks of all JavaScript libraries. They are super powerful and save a lot of time… when they work.

jQuery uses the sizzle selector engine and has some hardcore shorthand selectors to navigate the DOM, recently I have been having trouble combining ‘not‘ with ‘first‘ to exclude the first element from a group of elements. e.g. table rows.

I found that using the ‘greater than‘ selector made a useful alternative. Essentially all it does is select all elements which are greater than 0… which is the first. This creates a simpler solution, easier to remember and easier for someone else to read.

// the original combined method
$('table tr:not(:first)').css('background','red');

// the new method
$('table tr:gt(0)').css('background','red');