File tree Expand file tree Collapse file tree 3 files changed +129
-0
lines changed Expand file tree Collapse file tree 3 files changed +129
-0
lines changed Original file line number Diff line number Diff line change 1+ const copyText = document . querySelector ( "textarea[name=copyTxt" ) ;
2+ const finalText = document . querySelector ( "textarea[name=finalTxt" ) ;
3+ const moveBtn = document . querySelector ( ".moverBtn" ) ;
4+ const copyBtn = document . querySelector ( ".copyBtn" ) ;
5+ const output = document . querySelector ( ".output" ) ;
6+
7+ copyBtn . addEventListener ( "click" , ( ) => {
8+ let temp = copyText . value ;
9+ copyToClipBoard ( temp ) ;
10+ } ) ;
11+
12+ moveBtn . addEventListener ( "click" , ( ) => {
13+ let temp = copyText . value ;
14+ finalText . value = temp ;
15+ } ) ;
16+
17+ copyText . addEventListener ( "click" , ( ) => this . select ( ) ) ;
18+ finalText . addEventListener ( "click" , ( ) => this . select ( ) ) ;
19+
20+ function copyToClipBoard ( str ) {
21+ const outputContainer = document . querySelector ( ".output-container" ) ;
22+ const textarea = document . createElement ( "textarea" ) ;
23+ textarea . value = str ;
24+ outputContainer . appendChild ( textarea ) ;
25+ textarea . select ( ) ;
26+ document . execCommand ( "copy" ) ;
27+ outputContainer . removeChild ( textarea ) ;
28+ output . innerHTML = `<h3>Content Copied </h3>` ;
29+ output . classList . add ( "added" ) ;
30+ setTimeout ( ( ) => {
31+ output . classList . toggle ( "added" ) ;
32+ output . textContent = "" ;
33+ } , 2000 ) ;
34+ }
Original file line number Diff line number Diff line change 1+ < html lang ="en ">
2+ < head >
3+ < meta charset ="UTF-8 " />
4+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Copy and Move</ title >
7+ < link rel ="stylesheet " href ="style.css " />
8+ </ head >
9+ < body >
10+ < div class ="container ">
11+ < div class ="btns-container ">
12+ < button class ="copyBtn btn "> Copy Text</ button >
13+ </ div >
14+ < textarea name ="copyTxt " cols ="50 " rows ="3 "> Hello World</ textarea >
15+ </ div >
16+
17+ < div class ="output-container ">
18+ < div class ="output "> </ div >
19+ < button class ="moverBtn btn "> Move Text</ button >
20+ < textarea name ="finalTxt " cols ="50 " rows ="3 "> </ textarea >
21+ </ div >
22+
23+ < script src ="app.js "> </ script >
24+ </ body >
25+ </ html >
Original file line number Diff line number Diff line change 1+ * {
2+ padding : 0 ;
3+ margin : 0 ;
4+ box-sizing : border-box;
5+ }
6+
7+ body {
8+ height : 100vh ;
9+ background : blueviolet;
10+ font-family : sans-serif;
11+ display : grid;
12+ grid-template-columns : 2fr 2fr ;
13+ }
14+
15+ .container {
16+ display : flex;
17+ flex-direction : column;
18+ justify-content : center;
19+ align-items : center;
20+ border-right : 2px solid white;
21+ }
22+
23+ .btns-container {
24+ display : flex;
25+ justify-content : space-around;
26+ margin-bottom : 20px ;
27+ }
28+
29+ .btn {
30+ padding : 10px 20px ;
31+ margin : 10px ;
32+ cursor : pointer;
33+ }
34+
35+ textarea {
36+ margin : 10px ;
37+ outline : none;
38+ }
39+
40+ .output-container {
41+ display : flex;
42+ flex-direction : column;
43+ justify-content : center;
44+ align-items : center;
45+ text-align : center;
46+ position : relative;
47+ transition : 1s all ease;
48+ }
49+
50+ button {
51+ background-color : rgb (6 , 2 , 15 );
52+ border : none;
53+ color : # fff ;
54+ font-weight : bold;
55+ }
56+
57+ /* JavaScript */
58+ .added {
59+ position : absolute;
60+ bottom : 35px ;
61+ right : 20px ;
62+ display : flex;
63+ justify-content : center;
64+ align-items : center;
65+ text-align : center;
66+ background : # 000 ;
67+ color : white;
68+ width : 200px ;
69+ height : 50px ;
70+ }
You can’t perform that action at this time.
0 commit comments