Select text within a div tag by clicking on content of div tag?

M

M Wells

Hi All,

Wondering if anyone can tell me if it's possible to have Javascript
select the contents of a div tag with a unique id by clicking
somewhere in the contents of that div tag?

I want to make it as easy as possible for users to copy the contents
of the div tag for pasting in another page. So, instead of having them
use the mouse to drag the selection, which can sometimes be annoying,
I'd like to have them click anywhere within the div tag and have the
text automatically selected, and then they can simply right click and
select 'Copy'.

If this is possible, can anyone give me some advice on how to achieve
it?

As an alternative, if a div tag won't respond to an onClick event
itself, would it be possible to select the contents of that div tag
(assume, for eg, that it has the unique id of "Copy1") by clicking on
a button?

Any help with this would be much appreciated!

Much warmth,

Murray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top