Using jQuery, the following does not work in FF, but it is in IE
$(this).focus().select();
I looked around and found that you can use the timeout to get around this, but that’s not what I want to do if I can avoid it. Does anyone know another way to do this and make it work in FF?
Metropolis
. , setTimeout() - , Firefox. , : IE , focus(), Firefox , , , . setTimeout() , , , .
,
setTimeout(function() { $(Selecter).focus(); }, 0);
$('input').focus().select();
<input type="text" value="Some text" />
firefox. , , .
The solution to this that I just found is to use the code below.
[elementHere].setSelectionRange(0, [elementHere].value.length);
According to the Mozilla Developer Documentation , this selects the text but does not focus it. At least for me, this prevented problems with selecting text inside the focus event handler, because selecting text does not cause the element containing it to be focused again.
Source: https://habr.com/ru/post/1739507/More articles:Access 2007: Unrecognized Database Format - ms-access-2007MATLAB variable editor in Python - pythonWhy not use GDI + from ASP.NET - asp.netIQueryable :; / iframe> The extension method does not work - c #How to get a list of items when using cassandra - databaseDo PHP platforms enhance the development process? - phpCode Access User Rights - c #SequenceMatcher для нескольких входов, а не только для двух? - pythonUTF-8 Specification Task - utf-8Может ли MYSQL фильтровать по дате, если дата хранится в виде текста? ex "02/10/1984" - databaseAll Articles