Showing posts with label jQuey get button value. Show all posts
Showing posts with label jQuey get button value. Show all posts

Thursday, January 18, 2018

Retrieve button value

You can use jQuery val() function to retrieve buttons' value as shown below.

HTML

<button class="btn1"  name="btn1" value="button1">
    Label</button>

JavaScript

<script type="text/javascript">
    $(function() {
        $('.btn1').click(function() {
            alert($(this).val());
        });
    });
</script>


 This will display the value button1.

Regards,
Samitha