I'm looking to copy the text from a <p>
element with the ID of code and put it in an input field with the data-field-id of 6197c68b4c806 when a button is clicked.
How could I do this? I would like the code to be inline if that is possible.
My Answer:
You can achieve this using JavaScript. Here's an example of how you can do it:
html
Copy Text to Input Field
This is the text to copy
In this example, when the button is clicked, the `copyText` function is called. This function gets the text content of the `
` element with the ID of `code` and sets it as the value of the input field with the ID of `inputField`.
Rate this post
5 of 5 based on 9939 votesComments