FOR TEXT
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <div id="demo"> <p>The initial text</p> </div> <script> $(document).ready(function(){ $('#demo').text('The replaced text.'); }); </script> </body> </html>
FOR HTML
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <div id="demo"> <p>The initial text</p> </div> <script> $(document).ready(function(){ $('#demo').html('<b>The replaced text.</b>'); }); </script> </body> </html>