Eric Saboia Eric Saboia - 4 months ago 7
jQuery Question

How to get value of asp:Button with JavaScript

I don't understand very well how I get value of with JavaScript or JQuery?

I have this code:

<asp:Button ID="btnIdButton" runat="server" Text="Button"/>


In this case I need get value inside the button with id "btnIdButton". I tested some possibilites:

$("#btnIdButton").val()
$('input[id*=btnIdButton]').value()
$("#btnIdButton").text()
document.getElementById("#btnIdButton")


But it did not work.

Answer

You need to use "endsWith" selector like this:$("[id$=btnIdButton]")