Site icon Css3 Transition

Copy data in Html from div using JavaScript

Copy data in Html from div using JavaScript

Hi all, I am going to share a post with you about how to copy content from a div using JavaScript. Here I am going to perform three actions with three individual buttons separately.

All actions are given as below: –
1: Copy content from a div to another div on button click using JavaScript.
2: Reset content from div or input on button click using JavaScript.
3: Click to show copied data on button click using JavaScript.

Case 1: In this case html data will be copied on button click and saved in a variable and then it will get stored inside another div as you can see in javascript code:

Please take a look at java script code :-

Case 2: In this case we are just going to replace inner content of div with empty string to delete data inside using jquery.

Please take a look at java script code :-

Case 3: In this case I am going to just put stored variable into a alert to show copied data.

Please take a look at java script code:

HTML :-

CSS :-

Exit mobile version