jQuery blur not working on refreshing a page in IE
We have a textbox which contains a watermark in it with a normal focus and blur events in jQuery. In IE browsers alone, the problem is when we click on the textbox, the watermark disappears and then if we refresh the page. The cursor is focussed on the end of the watermark and the text we type gets appended to the watermark. I just want to cursor开发者_运维知识库 to disappear from the textbox on refreshing the page.
You can user .blur()
:
$( document ).ready( function() {
$( '#id_of_textfield' ).blur();
} );
If this doesn't work on IE, you could try forcing a focus on some other element on the page (because two elements can't have the focus at the same time this would remove it from the textfield). Based on a comment in the API, another thing to try is to give the field focus first before blurring: $( '#id_of_textfield' ).focus().blur();
精彩评论