【问题标题】:How to find and read metadata using jQuery (schema.org microformat)?如何使用 jQuery(schema.org 微格式)查找和读取元数据?
【发布时间】:2011-11-01 16:14:43
【问题描述】:

我正在构建一个 Google 地图应用程序,我想从我的 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>

有没有一种简单的方法来查询纬度和经度值而无需遍历所有内容?

【问题讨论】:

    标签: javascript jquery html


    【解决方案1】:

    你试过了吗?

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

    【讨论】:

      【解决方案2】:

      您可以像这样获取数据:

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

      【讨论】:

        猜你喜欢
        • 2015-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-08
        • 1970-01-01
        • 2014-01-26
        相关资源
        最近更新 更多