Run ยป
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#set_button").click(function(){ $("div").text("I am Set in this div element."); }); $("#get_button").click(function(){ var data=$("div").text(); alert(data); }); }); </script> </head> <body> <button id="set_button">Set the content</button> <br><br> <div id="div1" style="width:200px;height:80px;background-color:palegreen;">html() method jQuery</div><br> <button id="get_button">Get the content</button> <p>By click on the get the content button you can get the data of the div element</p> </body> </html>