I tried following code but no work:
<button type="button" class="btn btn-info filter-new" id="btn_Filter_New">New</button>
$("btn_Filter_New").click(function ()
{
var ButtonText = $(this).val();
}
jQuery val() method is used to get the value of an element. This function is used to set or return the value. Return value gives the value attribute of the first element.
String buttonText = button. getText(); I can get the id from a pressed button: int buttinID = view.
How Get button data attribute value in jQuery? Answer: Use the jQuery attr() Method You can simply use the jQuery attr() method to find the data-id attribute of an HTML element.
Answer: Use the jQuery text() method You can simply use the jQuery text() method to get all the text content inside an element. The text() method also return the text content of child elements.
Use the .text() function. Also use the id selector correctly #btn_Filter_New
.
$("#btn_Filter_New").click(function () {
var ButtonText = $(this).text();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With