Jquery 当我试图使用iframe获取属性值时,警报显示空值

Jquery 当我试图使用iframe获取属性值时,警报显示空值,jquery,dom,Jquery,Dom,我正试图从iframe获取节点元素的链接地址,但显示的是空值。您无法使用不同的域访问iframe。阅读更多信息,请访问以下是我获取超链接的工作代码: function getElement(){ var $link = $("#frametest").contents().find(".eod-topbox").children('a').first(); alert($link.attr('href')); } 是同一域的iFrame吗?否则,您将遇到跨域问题。没有iframe,您将没有其他

我正试图从iframe获取节点元素的链接地址,但显示的是空值。

您无法使用不同的域访问iframe。阅读更多信息,请访问

以下是我获取超链接的工作代码:

function getElement(){
var $link = $("#frametest").contents().find(".eod-topbox").children('a').first();
alert($link.attr('href'));
}

是同一域的iFrame吗?否则,您将遇到跨域问题。没有iframe,您将没有其他网址。那么您将无法访问iframe的内容。请尝试$frametest.contents.find'html'.html.find.eod topbox.children'a';我完成了,我将在8小时后发布,感谢所有:函数getElement{var$link=$frametest.contents.find.eod topbox.find'a';alert$link.attr'href';}
function getElement(){
  var $link = $("#frametest").contents().find(".eod-topbox").find('a');
  alert($link.attr('href'));
}