Question:Which option is correct to use the below function to set cursor position for textarea? Function:
$.fn.selectRange = function(start, end) {
    return this.each(function() {
        if (this.setSelectionRange) {
            this.focus();
            this.setSelectionRange(start, end);
        } else if (this.createTextRange) {
            var range = this.createTextRange();
            range.collapse(true);
            range.moveEnd('character', end);
            range.moveStart('character', start);
            range.select();
        }
    });
};
 

A $('#elem').selectRange(3,5); 

B $('#elem').selectRange(3 5); 

C $('#elem').selectRange(X:3,Y:5); 

D $('#elem').fn.selectRange(3,5); 

+ Answer
+ Report
Total Preview: 751

Copyright © 2024. Powered by Intellect Software Ltd