Skip to content

24 ways to impress your friends

Unobtrusively Mapping Microformats with jQuery

3 Comments

Comments are ordered by helpfulness, as indicated by you. Help us pick out the gems and discourage asshattery by voting on notable comments.

Got something to add? You can leave a comment below.

Marcos

I have come to love the ‘context’ option in a jQuery selector, and usually prefer it in ‘.each’ functions:

$(’.geo .latitude’,hcard).text();

instead of

hcard.find(’.geo .latitude’).text();

Just a matter of taste.

Great article, BTW. I love the microformats+jquery+gmaps combination, it gives warm fuzzies…

Matthew Pennell

It’s worth noting, for the benefit of any confused beginner jQuery users, that Simon’s initial jQuery(function () { line is more usually written as $(document).ready(function () {. Everyone has their own preferred way of writing that DOMReady wrapper; personally I prefer the second way, as it more clearly indicates that the code will be executed when the document is ready.

Marc

Great article, Simon. jQuery and Google Maps go together like bread and butter.

@Matthew: $(document).ready(function() { is actually a little different than how Simon is wrapping his code. He uses jQuery(function($) { which not only runs the code when the document loads, but also hide the $ namespace from other libraries. So, it doesn’t run the code until the document is loaded AND avoids conflicts between other libraries.

Impress us

Be friendly / use Textile