Adding text to an existing text element in javascript via DOM - Javascript jQuery

Javascript examples for jQuery:Text

Description

Adding text to an existing text element in javascript via DOM

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
      <script>
  $(document).ready(function(){
   $("#btn1").click(function(){
    $("p").append(" <b>Appended text</b>.");
   });//from   w  w  w .j  ava  2s  .co  m
  });
 
      </script> 
   </head> 
   <body> 
      <p>This is a paragraph.</p> 
      <p>This is another paragraph.</p> 
      <button id="btn1">Append text</button>  
   </body>
</html>

Related Tutorials