开发者

Removing highlighting of text in text box after switching tabs in jquery-ui-tabs

I am experiencing a weird issue with the jquery-ui tab object. If I highlight the text of an html input tag (type="text") that is on a tab, switch tabs, then come back to the original tab, this text is still highlighted. I can actually remove the highlighting before switching tabs, and when I come back, the text has been highlighted again. I have tried to remove this highlighting by calling .blur() on the textbox after the show event of the tab is triggered, but this does not work. Similarly, actually clicking on other parts of the page (which I take blur() to be the equivalent of) does not remove the highlighting of the text. Is there something e开发者_StackOverflow中文版lse I could be doing here?

Thanks.


I have solved the issue at hand by modifying the selectionStart property of the input DOM object. By setting it equal to the selectionEnd property, you ensure no text is highlighted. The selectionStart property was being changed on my original highlighting, so when I came back to the tab, the text was re-highlighted. Solution below.

$(this).find('input').each(function () {
    var input = document.getElementById($(this).attr("id"));
    try {
        input.selectionStart = input.selectionEnd;
    }
        catch (err) {
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜