Then we assign the onClick function as the value of the onclick property to each button element. The following code uses .is()inside an event handler and returns true if any radio button is selected. The following example will display the entered text in the input field on button click using JavaScript. The below are the 2 different approaches for getting or setting the value of the text input field: Using text value property: The text value property is used to set or return the value of a value attribute of the input field. var fired_button = $("button").val(); You have to use this to target the current button clicked instead of button that will select all buttons in the DOM, .val() makes it to get the value of the first button. In this post you will learn how to get multiple checkbox value in javascript . For instance, we can write: