jQuery Page Widget How to - Replace anchor text dynamically








Question

We would like to know how to replace anchor text dynamically.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from   w  ww .j av  a2  s .  c  o m-->
    $("#show-notif").html("pqr");
});
</script>
</head>
<body>
  <a href="" id="show-notif">abc</a>
</body>
</html>

The code above is rendered as follows: