Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<html>
<head>
</head>

<script type="text/javascript" language="javascript">
function f()
{
// how to copy text in div when Button Is clicked?!
}
</script>




<body>

<div style="width:200px;height:200px;background-color:gray;" id="div1">
abcdefgh

</div>
<input  type="button" value="Copy" onclick="f();"/>
</body>
</html>
Posted

JavaScript
function CopyToClipboard()

{

   CopiedTxt = document.selection.createRange();

   CopiedTxt.execCommand("Copy");

}
 
Share this answer
 
Hi,

You can do it using JQuery.

Please check JQuery example to Update Div inner Content[^]

Like,

JavaScript
$("#divID").html("Your div text");


Hope this helps you,

Thanks
-Amit Gajjar
 
Share this answer
 
Comments
Seyed Ahmad Mirzaee 12-Aug-12 13:17pm    
Thanks Its Very Funny
Mersi
AmitGajjar 13-Aug-12 0:29am    
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900