jQuery Page Widget How to - Change text








Question

We would like to know how to change text.

Answer


<!--  w w w. jav a2s . c om-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-2.1.0.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $('body > div.container').text('foo')
});
</script>
</head>
<body>
<body>
  <div>
    <div class='container'></div>
  </div>
  <div class='container'></div>
</body>
</body>
</html>

The code above is rendered as follows: