繁体   English   中英

我想从下面的代码超链接地址

[英]i want hyperlink address from below code

这是一些示例代码。 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);
 }

如果您需要link href属性,请尝试以下操作:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM