如何在 JavaScript 中搜索連結的 target 屬性值?


要在 JavaScript 中搜索連結的 target 屬性值,請使用target 屬性。您可以嘗試執行以下程式碼來獲取目標屬性的值。

示例

<!DOCTYPE html>
<html>
   <body>
      <p><a id = "qriesid" target="_self" href = "https://qries.com/" type = "text/html" >Qries</a></p>
      <script>
         var x = document.getElementById("qriesid").target;
         document.write("Value of the target attribute: "+x);
      </script>
   </body>
</html>

更新時間: 2020-05-23

291 次瀏覽

開啟你的 職業生涯

完成課程,獲得認證

開始
廣告