This is a follow up question to: Can you emulate the left-mouse button selection in JQuery?
The solution works fine in IE9, Firefox and Chrome, but it IE8 still does the browser's default selection i.e. highlighting the text.
isMouseDown = false
$('body').mousedown(function (e) {
e.preventDefault(); // Prevent default behavior
isMouseDown = true;
})
.mouseup(function (e) {
e.preventDefault(); // Prevent default behavior
isMouseDown = false;
});
$(".div").live("mouseenter", function (e) {
e.preventDefault(); // Prevent default behavior
if (isMouseDown) {
$(this).toggleClass("selected");
}
});
So I assume e.preventDefault()
is not working. Is there a way to fix this?