event.preventDefault();
return false;
event.stopPropagation();
any of them can prevent focus event from happening when I trigger a mousedown event in Firefox and chrome, but it failed in IE.In fact,chrome has another problem. when mousedowning, :hover css is not working. `
<input type="text" id="name">
<div id="suggest">
<div>mark</div>
<div>sam</div>
<div>john</div>
</div>
$("#name").focus(suggest.show).blur(suggest.hide);
` what I expected is, when I click the sub div, such as "sam",and then $("#name").val("sam"). but the problem is, when I press the mouse(just mousedown,not released), the $("#name").blur runs immediately and suggest div becomes hide.
Element: mousedown event The mousedown event is fired at an Element when a pointing device button is pressed while the pointer is inside the element. Note: This differs from the click event in that click is fired after a full click action occurs; that is, the mouse button is pressed and released while the pointer remains inside the same element.
The main difference between this event and focusin is that focusin bubbles while focus does not. The opposite of focus is blur. There are two ways of implementing event delegation for this event: by using the focusin event, or by setting the useCapture parameter of addEventListener () to true.
MouseDown or MouseUp event procedures specify actions that occur when a mouse button is pressed or released. MouseDown and MouseUp events enable you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keyboard modifiers.
For a MultiPage, the MouseDown event occurs when the user presses a mouse button over the control. For a TabStrip, the index argument identifies the tab where the user clicked. An index of -1 indicates the user did not click a tab.
You can use "unselectable" attribute for prevent losing focus in IE and mousedown handler for other.
<input type="text" id="name">
<div onmousedown="return false" unselectable="on" id="suggest">
<div unselectable="on">mark</div>
<div unselectable="on">sam</div>
<div unselectable="on">john</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With