How to Change the Text of a Button using jQuery?
Here is the question to Change the Text of a Button using jQuery. To do this task, we can use the following two methods:
- prop() method: It is used to set property values, it sets one or more property for the selected elements.
Syntax:
$(selector).prop(para1, para2)
-
Approach:
- Get the text from the <input> element.
- FIRST matched element is taken on the basis of para1.
- Change the value set for the selected element from para1 to para2.
Example:
<!DOCTYPE html><html><head><title>Change the Text of a Button using jQuery</title><scriptsrc=</script></head><bodystyle="text-align:center;"><h1style="color:green;">GeeksForGeeks</h1><h3>Change the Text of a Button using jQuery</h3><p>Click on button to change textfrom "Click" to "Prop Click"</p><inputtype="button"id="Geeks"value="Click"><script>$(document).ready(function() {$("input").click(function() {// Change text of input button$("#Geeks").prop("value", "Prop Click");});});</script></body></html>chevron_rightfilter_noneOutput:
Before Click on button:

After Click on button:

- The html() method: It set or return the content (innerHTML) of the selected elements.
Syntax:
$(selector).html(content)
-
Approach:
- Get the text from the <button> element.
- It matches the selector element.
- Change the value set for the selected element to content.
Example:
<!DOCTYPE html><html><head><title>How to Change the Text of aButton using jQuery?</title><scriptsrc=</script></head><bodystyle="text-align:center;"><h1style="color:green;">GeeksForGeeks</h1><h3>How to Change the Text of a Button using jQuery?</h3><p>Click on button to change textfrom "Click" to "Html Click"</p><buttontype="button"id="Geeks">Click</button><script>$(document).ready(function() {$("button").click(function() {// Change text of button element$("#Geeks").html("Html Click");});});</script></body></html>chevron_rightfilter_noneOutput:
Before Click on button:

After Click on button:
Recommended Posts:
- JQuery | Change the text of a span element
- How to change an input button image using CSS?
- How to change the font of HTML5 Canvas using a button in Angular.js?
- How to change the background color after clicking the button in JavaScript ?
- CSS | Animation to Change the Hover State of a Button/Image
- How to align button to right side of text box in Bootstrap?
- How to change the text of a label using JavaScript ?
- JavaScript | Change the text of a span element
- jQuery | :button Selector
- How to get the ID of the clicked button using JavaScript / jQuery ?
- How to check a radio button with jQuery?
- How to know which radio button is selected using jQuery?
- How to unchecked a radio button using JavaScript/jQuery?
- jQuery | change() with Examples
- How to change the element id using jQuery ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



