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


要在 JavaScript 中搜索連結目標屬性的值,請使用 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>

更新於:23-05-2020

293 次瀏覽

開啟您的職業

完成課程獲得認證

開始
廣告
© . All rights reserved.