0

Open Graph should use this syntax:

<meta property="og:title" content="This is the title" />

but some website use name instead of property (also stackoverflow, check it out this question html). And I've also seen other parameters, such as data-og.

So, I'd like to select/filter an element with jQuert that contains og:title as value instead of property, because this:

$mypage.filter("meta[property='og:title']").attr("content");

won't work for example if I parser a stackoverflow page (which has meta name='og:title').

How can I do this in jQuery? Filter by "value-destination"? Tried with:

$mypage.filter("meta[*='og:title']").attr("content");

but it give to me fields that does not contains og:title

4

1 回答 1

1

您可以使用多重选择器:

$('meta[property="og:title"], meta[name="og:title"]').first().attr('content');

如果有多个标签仅在“名称”或“属性”属性上有所不同,则过滤掉第一个对象。

于 2013-10-11T10:01:36.340 回答