Change Button text in jQuery


Change Button text in jQuery : You Can use jQuery .attr() method to change button text. You can change the button text label at run time using this method. Here in this tutorial we are going to explain how you can change the button text in jQuery. We will explain this with various examples and online demo.


Change Button text in jQuery

You can change the button text as below –

Example 1

Change Button text in jQuery:

<script type="text/javascript">
function changeBtnText(){
    $("#add").attr('value', 'Save Data'); 
}
</script>

Try it »

Example 2

If you are using button tag in this style –

<button type="button" id="add"><span>Add</span></button>

Change Button text in jQuery:

<script type="text/javascript">
function changeBtnText(){
    $("#add span").text('Save Data'); 
}
</script>

Try it »

If you run above example it will produce output something like this –

Change Button text in jQuery


Advertisements

Add Comment

📖 Read More