Reputation: 5559
Is it possible to right click on a textarea to select the text and bring up the options dialogue at the same time?
I want to eliminate the additional click of left clicking to select all the text and then right clicking to select 'copy' in
<textarea onclick="this.focus();this.select()" readonly="readonly">
example text
</textarea>
Upvotes: 1
Views: 3548
Reputation:
Use the oncontextmenu event as in this example:
<div oncontextmenu="this.focus();this.select();return false;" readonly="readonly">
example text
</div>
Use "return false" if you don't want the standard context menu to pop up, just in case you changed your mind.
Upvotes: 0
Reputation: 4294
Just a different way to implement the RIGHT CLICK by Jquery.
event.which == 3 means right click.
$('textarea').mousedown(function(event) {
if(event.which == 3){
var THIS = $(this);
THIS.focus();
THIS.select();
}
});
Upvotes: 0
Reputation: 152
oncontextmenu is the event you are looking for.
<textarea oncontextmenu="this.focus();this.select()" readonly="readonly">
example text
</textarea>
for reference http://jsfiddle.net/EyNWz/
hope it helps.
Upvotes: 1