How to find and read metadata using jQuery (schema.org microformat)?

I am building a Google Maps application and I would like to read the metadata, as indicated by schema.org , from my HTML to build my map markers.

For example:

<li itemscope="itemscope" itemtype="http://schema.org/LocalBusiness"> ...some html... <div class="geo" itemprop="geo" itemscope="itemscope" itemtype="http://schema.org/GeoCoordinates"> <meta itemprop="latitude" content="43.681505" /> <meta itemprop="longitude" content="-79.294455" /> </div> </li> 

Is there an easy way to query latitude and longitude values ​​without going through a loop through everything?

+8
javascript jquery html
source share
2 answers

Have you tried this?

 jQuery(function($){ var latitude = $('.geo meta[itemprop="latitude"]').attr("content"); var longitude = $('.geo meta[itemprop="longitude"]').attr("content"); }); 
+18
source share

You can get the data like this:

$('meta[itemprop="latitude"]').attr('content')

+3
source share

All Articles