如何使用jQuery查找和读取元数据(schema.org微格式)



我正在构建一个Google Maps应用程序,我想从我的HTML中读出schema.org指定的元数据,以绘制我的地图标记。

例如:

<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>

是否有一种简单的方法来查询出纬度和经度值,而不需要通过所有的循环?

你试过吗?

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

您可以这样获取数据:

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

相关内容

最新更新