print html as plain text - Javascript jQuery

Javascript examples for jQuery:Text

Description

print html as plain text

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> 
      <script>
$(document).ready(function(){
    $("button").click(function(){
        $("#elem").text('This <b>contains</b> html');
    });//  w  w  w .  j  av a2s  .co m
});

      </script> 
   </head> 
   <body> 
      <button>Click ME!!</button> 
      <p id="elem">This is a paragraph.</p>  
   </body>
</html>

Related Tutorials