Prev Demo
jQuery
>
.Text() - Get Set Text Of Element
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <style> #div3{ color:blue; } </style> </head> <body> <p id="div1">This is DIV1</p> <p id="div2">This is DIV2</p> <p id="div3">This is DIV3 NOT DIV2</p> <br/> <br/> <p>The text in the DIV3 is replaced by the text in DIV2</p> <script> $("#div3").html($("#div2").text()); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output