jQuery HTML Element How to - Remove href attribute








Question

We would like to know how to remove href attribute.

Answer


<!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(){<!-- w w w.j av a2  s . c om-->
  $("#SomeLink").attr('href','');
}
</script>
</head>
<body>
  <a id="SomeLink" title="My Title" href='http://cnn.com'>Click
    Here</a>
  <input type="button" value="Remove href attribute" onclick="disbleLink();" />
</body>
</html>

The code above is rendered as follows: