Safer $.fn.selectEnd
When `this.length` is 0, `this.val().length` will become `undefined.length` and cause a TypeError.
This commit is contained in:
@@ -102,7 +102,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.fn.selectEnd = function(){
|
$.fn.selectEnd = function(){
|
||||||
this.selectRange(this.val().length, this.val().length);
|
if (this.length) {
|
||||||
|
this.selectRange(this.val().length, this.val().length);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user