There is a specific issue I am facing with text selection on the page. When I apply this code snippet, the selected text does not get de-selected even after clicking .container
:
jQuery('.container').on("mousedown", function(){
jQuery('.block').addClass('myclass');
});
However, when I use this alternative code, the selected text gets de-selected:
jQuery('.container').on("click", function(){
jQuery('.block').addClass('myclass');
});
The problem with the first snippet is that it removes the .myclass
as soon as I release the mouse button. Is there any way to retain my text selection while clicking on .container
?