I’ve had some time to use jQuery now and I’ve really liked it. I especially appreciated Yehuda’s comment on my blog earlier that lead me to try out livequery. I’ll never see app development in javascript the same way (thanks, wycats!).

While I don’t have time to blog about livequery this morning, I would like to drop a few tips that I’ve picked up as I’ve used the powerful querying system that is jQuery.

1. When using the ‘prev + next’ selector, you might think that this type of query is only useful for getting a set of the ‘next’ elements. Actually, you can get the set of next elements, and then ask for the ‘prev’ of each one:

$("label + input").prev().css("font-weight", "bold")

The above code will make bold all labels that are followed by an ‘input’ tag.

2. Logical AND, OR and NOT are possible in jQuery’s using set commands and/or its query language. The following couplets are equivalent:

AND:

$('.class-a.class-b')
$('.class-a').filter('.class-b')

OR:

$('.class-a,.class-b)
$('.class-a).add('.class-b')

NOT:

$('.class-a:not(.class-b)')
$('.class-a').not('.class-b')