Count number of times Button is clicked in JavaScript and jQuery

Last Reply one year ago By pandeyism

Posted one year ago

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

Posted one year ago Modified on one year 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