次のようなことを試してください:
$(document).ready(function(){
var isDown = false; // Tracks status of mouse button
$(document).mousedown(function() {
isDown = true; // When mouse goes down, set isDown to true
})
.mouseup(function() {
isDown = false; // When mouse goes up, set isDown to false
});
$(".node").mouseover(function(){
if(isDown) { // Only change css if mouse is down
$(this).css({background:"#333333"});
}
});
});
編集:
個々のアイテムの選択に対して個別mousedown
に実行することをお勧めします。.node
$('.node').mousedown(function() {
$(this).css({background:"#333333"});
});
編集:
Here's an alternative method using bind
and unbind
.
$(document).mousedown(function() {
$(".node").bind('mouseover',function(){
$(this).css({background:"#333333"});
});
})
.mouseup(function() {
$(".node").unbind('mouseover');
});
$('.node').mousedown(function() {
$(this).css({background:"#333333"});
});