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.
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.
2
Answers
First you need to access the element you want to copy the text from with:
This will save the text existing in the element.
Then you select the input, using the same technique and then do:
.value = text.
Also add an event listener to the button you want to click to trigger this:
Should do the trick.
You have to follow this above code, hopefully you can solve this