Safer $.fn.selectEnd

When `this.length` is 0, `this.val().length` will become `undefined.length` and cause a TypeError.
This commit is contained in:
xiaody
2013-08-15 01:09:59 +08:00
parent ea787e1644
commit 0d680a4a45

View File

@@ -102,7 +102,9 @@
};
$.fn.selectEnd = function(){
this.selectRange(this.val().length, this.val().length);
if (this.length) {
this.selectRange(this.val().length, this.val().length);
}
return this;
}
})();