Safer $.fn.selectEnd

When `this.length` is 0, `this.val().length` will become `undefined.length` and cause a TypeError.
Merge pull request #1937 from xiaody/patch-2

Safer $.fn.selectEnd