What are the difference between text and html method in jQuery?
Hi makenzi.exc,
Refer below example.
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> body { font-family: Arial; font-size: 10pt; } </style> </head> <body> <div id="message1"></div> <hr /> <div id="message2"></div> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script type="text/javascript"> $(function () { // jQuery html. $("#message1").html('<a href="https://www.aspsnippets.com">ASPSnippets</a>'); // jQuery text. $("#message2").text('<a href="https://www.aspsnippets.com">ASPSnippets</a>'); }); </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.