Count number of times Button is clicked in JavaScript and jQuery

Last Reply 11 months ago By pandeyism

Posted 11 months ago

is there any way to count number of clicks on a button using html control in asp.net using jquery.

Posted 11 months ago Modified on 11 months ago

Hi himani895,

Please refer below sample.

HTML

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    var count = 0;
    function Count() {
        count++;
        $('#lblShow').text(count);
        return false;
    }
</script>
<div>
    <input type="submit" name="btnCount" value="Count" onclick="return Count();" id="btnCount" />
    <span id="lblShow"></span>
</div>

Demo