jQuery: chiedere conferma di un'azione all'utente

jQuery: chiedere conferma di un'azione all'utente

In jQuery è semplice chiedere conferma di un'azione all'utente.

Possiamo scrivere il seguente codice jQuery:


(function( $ ) {
    $(function() {
        $( ".action" ).on( "click", function( e ) {
            e.preventDefault();
            var $a = $( this );
            if( confirm( "Are you sure?" ) ) {
                window.location = $a.attr( "href" );
            }
        });
    });
})( jQuery );

Torna su