Codelab Editor
Free Online HTML Editor
Run
Learn HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery Get HTML Content</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <style> body { font-family: Arial, sans-serif; padding: 30px; background: #f4f4f4; } h2 { color: #333; } p#content { background: #fff; padding: 15px; border: 1px solid #ccc; } button { margin-top: 10px; padding: 10px 15px; border: none; background: #1976d2; color: white; cursor: pointer; border-radius: 4px; } #result { margin-top: 20px; padding: 10px; background: #e3f2fd; border-left: 4px solid #1976d2; white-space: pre-wrap; } </style> </head> <body> <h2>Get HTML Content Using jQuery</h2> <p>This example demonstrates how to retrieve the inner HTML of an element, including nested tags, using the <code>.html()</code> method in jQuery.</p> <p id="content">This is a <strong>bold</strong> and <em>italic</em> <span style="color:green;">paragraph</span>.</p> <button id="getHtml">Get HTML Content</button> <div id="result"></div> <script> $(document).ready(function(){ $("#getHtml").click(function(){ var htmlContent = $("#content").html(); $("#result").text(htmlContent); }); }); </script> </body> </html>
Editor Commands
Ctrl
F
Find
Ctrl
G
Find Next
Ctrl
⇧
G
Find Previous
Ctrl
⇧
F
Find & Replace
Ctrl
]
Indent Code Right
Ctrl
[
Indent Code Left
⇧
Tab
Auto Indent Code
Ctrl
/
Line Comment
Ctrl
Alt
/
Block Comment
TutsInsider Actions
Alt
S
Run Code
Ctrl
C
Copy Editor Code
Ctrl
A
Select All Editor Code
Ctrl
S
Save/Download
Ctrl
Alt
X
Rotate
Ctrl
Alt
T
Switch Theme
Ctrl
⇧
C
Open Console
Esc
Close Console