以下是一些示例代码。 iframe内容的节点结构就像这样。
<iframe>
<div class="eod-topbox">
<a href="some link">dfdf</a>
<div id="something">
<img src="">
</div>
</div>
</iframe>
我正在尝试这种方式。请提供任何有用的答案,以便我可以从iframe的eod topbox类中获取超链接地址。
function getElement(){
var iBody = $("#frametest").contents().find(".eod-topbox").html();
document.getElementById("demo").innerHtml=iBody;
alert(iBody);
}
答案 0 :(得分:0)
如果您需要link
href
属性,请尝试以下操作:
function getElement(){
var $link = $("#frametest").contents().find(".eod-topbox").children('a').first();
alert($link.attr('href'));
}