App下載
首頁javascriptanchorjQuery HTML Element - 如何刪除href屬性

jQuery HTML Element - 如何刪除href屬性

我們想知道如何刪除href屬性。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.1.js'></script>
<script type='text/javascript'>
function disbleLink(){
  $("#SomeLink").attr('href','');
}
</script>
</head>
<body>
  <a id="SomeLink" title="My Title" >Click
    Here</a>
  <input type="button" value="Remove href attribute" onclick="disbleLink();" />
</body>
</html>