views:

2002

answers:

2

I have the following jQuery code (similar to this question) that works in Firefox and IE, but fails (no errors, just doesn't work) in Chrome and Safari. Any ideas for a workaround?

$("#souper_fancy").focus(function() { $(this).select() });
+1  A: 

This works fine for input type="text" elements. What kind of element is #souper_fancy?

$("#souper_fancy").focus(function() {
    $(this).select();
});
Joe Chung
it's a type="text" element. I tried $("input[type=text]") as well. Still not working with jQuery 1.3.2 in Safari.
+9  A: 

It's the onmouseup event that is causing the selection to get unselected, so you just need to add:

$("#souper_fancy").mouseup(function(e){
 e.preventDefault();
});
You sir are a gentleman and a scholar.
More ref on the bug here : http://code.google.com/p/chromium/issues/detail?id=4505
Rajat