code: function(elem, pos) {
              if (elem.setSelectionRange) {
                  elem.setSelectionRange(pos, pos);
              } else if (elem.createTextRange) {
                  var range = elem.createTextRange();
                  range.collapse(true);
                  range.moveEnd('character', pos);
                  range.moveStart('character', pos);
                  range.select();
              }
          }
docs: set caret position in input
  see http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area