【发布时间】:2013-07-10 23:02:23
【问题描述】:
我有一个包含以下内容的 HTML 文件
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" name="viewport">
<meta content="desc goes here" name="description">
<meta content="auth name" name="author">
<title>builder 1.0</title>
</head>
<body>
<iframe width="100%" height="100%" src="http://domain.com/a.html" name="cxsideframe" scrolling:'no';="" id="frame1" style="overflow:hidden;">
</iframe>
</body></html>
a.html的内容是
<html>
<head>
<meta charset="utf-8">
<title>builder v1.0</title>
<body>
<img src="http://example.com/images/01._V397411194_.png" style="display:none" alt=""/>
<img src="http://example.com/images/V386942464_.gif" style="display:none" alt="" />
</body></html>
我需要知道一种使用jQuery或javascript从父页面获取父页面html的元标记和图像列表的方法。
$('meta[name=author]').attr("content"); does not work for me
【问题讨论】:
-
这可能会有所帮助:stackoverflow.com/a/1133526/921204 - 将
$(elementid).attr(attributeName)替换为$('meta[name=author]').attr("content") -
@techfoobar 它返回 undefined
-
您使用的是哪个版本的 jquery?
-
@Thirumalaimurugan 1.7.1
-
@Zubin 从 jQuery 1.6 开始,
.prop()方法提供了一种显式检索属性值的方法,而.attr()检索属性。将attr更改为prop并检查
标签: javascript jquery dom html-parsing