Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>jQuery text('') Method</title> <style> body { font-family: Arial, sans-serif; padding: 40px; background-color: #f4f4f4; } h1 { color: #333; } p { font-size: 16px; color: #444; } .wrapper { background-color: #fff; padding: 20px; border: 1px solid #ccc; border-radius: 6px; margin-top: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); } #contentBox { background: #FFF8E1; color: #F57F17; padding: 15px; margin-bottom: 15px; border: 2px dashed #FFC107; border-radius: 6px; } button { padding: 10px 20px; background-color: #FFC107; color: #000; font-size: 14px; border: none; border-radius: 4px; cursor: pointer; margin-right: 10px; } button:hover { background-color: #FFA000; } </style> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> </head> <body> <h1>jQuery text('') Method</h1> <p> The <code>text('')</code> method removes only text content from the element. Any nested HTML tags or elements will stay intact. </p> <div class="wrapper"> <div id="contentBox"> <strong>This is <span>some text</span> content</strong><br> <em>Only the text will be removed using <code>text('')</code>.</em> </div> <button id="removeText">Remove Text</button> </div> <script> $(document).ready(function(){ $('#removeText').click(function(){ $('#contentBox').text(''); }); }); </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