开发者

Javascript de-focus textfield input

I have a modal that I pop up with jQuery with a textfield on which I want to trigger the focus() event.

Problem is the fextfield IS allready focused.. In most browsers it is even highlighted. (I have no idea why?)

How can I de-focus or de-select the text so I can use the focus() event?

<input type="text" class="shortcut" id="input-shortcut" value="<?= $shortcut_url; ?>" />

$(".shortcut").focus(function开发者_JAVA百科() { 
    $(this).addClass("focus");
    $(this).select();
}).blur(function() { 
    $(this).removeClass("focus"); 
});


Use $("#element").blur();

jQuery documentation of blur


Use Jquery's blur() function. Which is basically like "out of focus"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜