Change HTML Button Text using JQuery

Change HTML Button Text using JQuery

In this tutorial we will see how to Change HTML Button Text using JQuery. JQuery html() method is used which will change the text of HTML Button Element.

HTML Code

HTML Code is given below, In this code we have a button tag whose text will be changed.

<!DOCTYPE html>
<html lang="en">
<head>
<title>Change HTML Button Text using JQuery</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
</head>
<body>
<button type="button">Change My Text!</button>
</body>
</html>

JQuery Code

JQuery Code is given below, In this code JQuery html() method is used which sets or returns the inner content of selected element.

In this example html() method will change the text of button tag on click.


<script>
$(document).ready(function(){
$("button").click(function(){
$(this).html("Text Changed :)");
});
});
</script>

Demo

Video Tutorial

Watch video tutorial on how to Change HTML Button Text using JQuery.

Post a Comment

Previous Post Next Post