How to change text inside an element using jQuery
In this article, we will explain to you how to change text inside an element using jQuery. so we will give you a simple example of how to change text inside an element using jQuery.
Example: jQuery text() Method
In this example, we use the jQuery text() method to change text inside an element. so you can follow the below example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").text("Yellow"); }); }); </script> </head> <body> <button>Change text inside an element</button> <p>Red</p> <p>Green</p> </body> </html> |
Please follow and like us: