แก้ไขโค้ด:
เห็นผล »
ลองตัวเอง - ©
w3ii.com
<
!DOCTYPE
html
>
<
html
>
<
body
>
<
input
type
="text"
oncopy
="myFunction()"
value
="Try to copy this text"
>
<
p
id
="demo"
>
<
/p
>
<
script
>
function
myFunction() {
document.getElementById(
"demo"
).innerHTML =
"You copied text!"
}
<
/script
>
<
/body
>
<
/html
>
<!DOCTYPE html> <html> <body> <input type="text" oncopy="myFunction()" value="Try to copy this text"> <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = "You copied text!" } </script> </body> </html>