mousemoveのときに一度「test」にアラートを出し、次にmousemoveイベントを削除したいというコードがありますが、使用しunbind()
ていないようですが、誰かが私を助けてくれますか?
$(document).ready( function(){
$(document).mousemove( function(){
alert( "test" );
$(document).unbind("mousemove");
});
});
mousemoveのときに一度「test」にアラートを出し、次にmousemoveイベントを削除したいというコードがありますが、使用しunbind()
ていないようですが、誰かが私を助けてくれますか?
$(document).ready( function(){
$(document).mousemove( function(){
alert( "test" );
$(document).unbind("mousemove");
});
});
$ .one()を使用して、1回限りの使用イベントハンドラーをバインドするだけです。
$(document).ready(function() {
$(document).one("mousemove", function() {
alert("test");
});
});
バインド/バインド解除ではなく、オンとオフになっていると思います
やってみてください
$(document).off("mousemove");