簡體   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