Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

This is a test about the code snippet function for this question on WPSE, there have not htis nice feature: http://wordpress.stackexchange.com/questions/194271/how-to-disabled-a-button-when-press-three-times/194272https://wordpress.stackexchange.com/questions/194271/how-to-disabled-a-button-when-press-three-times/194272

jQuery( document ).ready( function( $ ) {

    var counter = 1,
        element = 'input.edit';

    $( element ).click( function(e) {
        counter ++;
        // for control debugging in console
        console.log( counter );
        if ( counter > 3 ) {
            $( element ).attr( 'disabled', true );
        }
    } )

} );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="input" class="edit" value="Click here">

This is a test about the code snippet function for this question on WPSE, there have not htis nice feature: http://wordpress.stackexchange.com/questions/194271/how-to-disabled-a-button-when-press-three-times/194272

jQuery( document ).ready( function( $ ) {

    var counter = 1,
        element = 'input.edit';

    $( element ).click( function(e) {
        counter ++;
        // for control debugging in console
        console.log( counter );
        if ( counter > 3 ) {
            $( element ).attr( 'disabled', true );
        }
    } )

} );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="input" class="edit" value="Click here">

This is a test about the code snippet function for this question on WPSE, there have not htis nice feature: https://wordpress.stackexchange.com/questions/194271/how-to-disabled-a-button-when-press-three-times/194272

jQuery( document ).ready( function( $ ) {

    var counter = 1,
        element = 'input.edit';

    $( element ).click( function(e) {
        counter ++;
        // for control debugging in console
        console.log( counter );
        if ( counter > 3 ) {
            $( element ).attr( 'disabled', true );
        }
    } )

} );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="input" class="edit" value="Click here">

Source Link
bueltge
  • 2.4k
  • 12
  • 2

This is a test about the code snippet function for this question on WPSE, there have not htis nice feature: http://wordpress.stackexchange.com/questions/194271/how-to-disabled-a-button-when-press-three-times/194272

jQuery( document ).ready( function( $ ) {

    var counter = 1,
        element = 'input.edit';

    $( element ).click( function(e) {
        counter ++;
        // for control debugging in console
        console.log( counter );
        if ( counter > 3 ) {
            $( element ).attr( 'disabled', true );
        }
    } )

} );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="input" class="edit" value="Click here">

Post Made Community Wiki by bueltge