jQuery in Action, 3rd edition
The moose likes HTML, CSS and JavaScript and the fly likes Copy text from DIV Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Copy text from DIV" Watch "Copy text from DIV" New topic

Copy text from DIV

kwon yuu

Joined: Jul 20, 2010
Posts: 8
Hi all,

My interface is written using div.
I would like to copy some text from the interface when the application is run.
But I could not able to do this because of div.
Is there a way to copy certain text from div?
Hope someone can give me a guideline.
Ankit Garg

Joined: Aug 03, 2008
Posts: 9452

I'm not really sure what you are trying to say here. You can easily get the contents of a div (or any other HTML element) by assigning an id to the HTML element and then using getElementById('myId').innerHTML

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
kwon yuu

Joined: Jul 20, 2010
Posts: 8
What I meant is I can't select or copy/paste the text that I wrote within div.
I don't want to get all div elements. I don't understand why I can select or do copy/paste after I do my layout with div.
Any idea?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63533

The use of <div> elements does not prevent copying to the clipboard.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Copy text from DIV
It's not a secret anymore!