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 removeData() Method</title> <style> body { font-family: Arial, sans-serif; padding: 40px; background-color: #f9f9f9; } h1 { color: #333; } p { font-size: 16px; color: #444; } .content-box { padding: 20px; background-color: #fff; border: 1px solid #ccc; border-radius: 6px; margin-top: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); } .data-box { padding: 15px; border: 2px dashed #4CAF50; border-radius: 6px; background-color: #E8F5E9; color: #1B5E20; margin-bottom: 15px; } button { margin-right: 10px; padding: 10px 20px; background-color: #4CAF50; color: white; font-size: 14px; border: none; border-radius: 4px; cursor: pointer; } button:hover { background-color: #388E3C; } </style> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> </head> <body> <h1>jQuery removeData() Method</h1> <p> The <code>removeData()</code> method removes previously stored data from elements using jQuery’s <code>data()</code>. This example demonstrates how to store, retrieve, and then remove custom data from a div element. </p> <div class="content-box"> <div class="data-box" id="dataBox"> Click the buttons to manage custom data on this box. </div> <button id="storeDataBtn">Store Data</button> <button id="readDataBtn">Read Data</button> <button id="removeDataBtn">Remove Data</button> </div> <script> $(document).ready(function() { $('#storeDataBtn').click(function() { $('#dataBox').data('customKey', 'Hello, jQuery!'); $('#dataBox').text('Data stored!'); }); $('#readDataBtn').click(function() { const stored = $('#dataBox').data('customKey'); if (stored) { $('#dataBox').text('Retrieved Data: ' + stored); } else { $('#dataBox').text('No data found.'); } }); $('#removeDataBtn').click(function() { $('#dataBox').removeData('customKey'); $('#dataBox').text('Data removed.'); }); }); </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