Wednesday, 20 January 2021

jQuery - find ID of clicked control

 Watch this example on YouTube


 

 

@using (Html.BeginForm("Index", "Home"))
{
    
    <input type="submit" id="btnSubmit1"  value="Submit" />
    <input type="submit" id="btnSubmit2" value="Submit" />
}

@section Scripts{
<script type="text/javascript">
    $(document).ready(function () {
        jQuery('input[type=submit]').click(function(event){
     
                alert($(this).attr('id'))
            });
        });
</script>

No comments:

Post a Comment