Bhagya Bhagya - 4 months ago 6
jQuery Question

jQuery changing Button value not working

I am trying to change button value dynamically but still no success read so many answers but for me no luck

JS

$("#d").attr("value","dayaw");


HTML

<button id="d"></button>


here is fiddle

Answer

Not sure about attr function, but you can use text to achieve your requirement.

For Static value

$("#d").text("<your-text>")

You can also use like below for dynamic value

var lable = "new lable";    
$("#d").text(label)

Here is updated fiddle

Comments