2012-12-23 13 views

risposta

0

Beh, ho trovato che return false risolve il problema in modo più appropriato.

Finché viene chiamato e.preventDefault(), verrà impedita anche la selezione del testo (probabilmente alcune altre azioni) e non può essere annullata.

ho aggiunto return false-mousedown sulle immagini solo

if(e.target.tagName.toLowerCase() == 'img') { 

    return false; 

    // e.preventDefault() also does the job 
    // but it prevents all default action 
    // and can not be undone 
} 

violino aggiornamento: http://jsfiddle.net/kVFTZ/4/

4

Abbastanza facile da risolvere. Aggiungi event.preventDefault(); alla tua funzione salvaspazio.

jsFiddle example

$(document).on('mousedown', function(event) { 
    event.preventDefault(); 
    $('#info').text('Now move the mouse and then release'); 
    $('#log').text('mouse down fired'); 
}).on('mouseup', function() { 
    $('#log').text('mouse up fired'); 
}); 

+0

grazie, ma 'preventDefault' dovrebbe andare dopo altro codice che deve essere eseguito (ele.text() in questo Astuccio). – user1643156

Problemi correlati