源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ alert($("#runoob").attr("href")); }); }); </script> </head> <body> <p><a href="http://www.sharebody.com" id="runoob">教程</a></p> <button>顯示 href 屬性的值</button> </body> </html>
運行結果