0
点赞
收藏
分享

微信扫一扫

Failed to execute 'setSelectionRange' on 'HTMLInputElement'

JamFF 2023-05-22 阅读 50



jcubic commented on 7 Jan 2016


When I use number input I've got error in Google Chrome




Uncaught InvalidStateError: Failed to execute 'setSelectionRange' on 'HTMLInputElement': 
The input element's type ('number') does not support selection.





Failed to execute


jcubic commented on 7 Jan 2016



The fix will be something like:




activate: function() {
            if(this.$input.is(':visible')) {
                this.$input.focus();
                var type = this.$input.attr('type');
                if (type && type.match(/^(text|search|password|tel|url)$/i) || !type) {
                    $.fn.editableutils.setCursorPosition(this.$input.get(0), this.$input.val().length);
                }
                if(this.toggleClear) {
                    this.toggleClear();
                }
            }
        },



Failed to execute



 



zorosun commented on 1 Aug 2016



@akakoori you might want to look at this

Pull request

I fixed it by inserting



(function() {
      var original = $.fn.editableutils.setCursorPosition;
      $.fn.editableutils.setCursorPosition = function() {
          try {
              original.apply(this, Array.prototype.slice.call(arguments));
          } catch (e) { /* noop */ }
      };
  })();






当然,你也可以

min= "0"

举报

相关推荐

0 条评论