Quantcast
Viewing latest article 20
Browse Latest Browse All 41

Answer by Just code for Select All Text in INPUT=TEXT

$(":input:text:eq("+ nxtIdx +")") 

this selector returns an array so you can either use [0] indexing or use val() to get the value which will return the first element matches to the selector.

You can use $(":input:text:eq("+ nxtIdx +")")[0] or $(":input:text:eq("+ nxtIdx +")").val()

$(function() {  $('input:text:first').focus();  var $inp = $('input:text');  $inp.bind('keydown', function(e) {    var key = e.which;    if (key == 13) {      e.preventDefault();      var nxtIdx = $inp.index(this) + 1;      if ($(":input:text:eq("+ nxtIdx +")").length > 0) {        $(":input:text:eq("+ nxtIdx +")").focus();        $(":input:text:eq("+ nxtIdx +")")[0].setSelectionRange(0, $(":input:text:eq("+ nxtIdx +")")[0].value.length)      }    }  });});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><input /><input />

Viewing latest article 20
Browse Latest Browse All 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>