I can't work out why I can't get the the content of a textarea to be selected when the textarea receives focus.
Please visit a live example here: http://jsfiddle.net/mikkelbreum/aSvst/1
Using jQuery, this is my code. (IN SAFARI) It makes the text selected in case of the click event, but not the focus event:
$('textarea.automarkup')
.mouseup(function(e){
// fixes safari/chrome problem
e.preventDefault();
})
.focus(function(e){
$(this).select();
})
.click(function(e){
$(this).select();
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…