File tree Expand file tree Collapse file tree 3 files changed +72
-0
lines changed
Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Portapapeles</ title >
7+ < link rel ="stylesheet " href ="styles.css ">
8+ </ head >
9+ < body >
10+ < section >
11+ < form action ="">
12+ < legend > Obtener 20% de descuento con el cupón</ legend >
13+ < input type ="text " name ="coupon " id ="coupon " placeholder ="BOCAJRS12 ">
14+ < button id ="copy "> Copiar</ button >
15+ </ form >
16+ </ section >
17+ < script src ="clipboard.js "> </ script >
18+ </ body >
19+ </ html >
Original file line number Diff line number Diff line change 1+ const d = document ,
2+ n = navigator ;
3+
4+ console . log ( n . clipboard ) ;
5+ const $copy = d . getElementById ( "copy" ) ;
6+ const $coupon = d . getElementById ( "coupon" ) ;
7+ d . addEventListener ( "click" , e => {
8+ e . preventDefault ( ) ;
9+ if ( e . target === $copy ) {
10+ //n.clipboard.readText().then( (`${$coupon.value}`))
11+ console . log ( $coupon . placeholder )
12+ const datos = {
13+ "text/plain" : `${ $coupon . placeholder } `
14+ }
15+ const action = new ClipboardItem ( datos ) ;
16+ n . clipboard . write ( [ action ] ) ;
17+ console . log ( action )
18+ //action.clipboardData.items.add(`${$coupon.value}`,'text/plain');
19+
20+ //d.dispatchEvent(action)
21+ }
22+ } )
Original file line number Diff line number Diff line change 1+ * {
2+ margin : 0 ;
3+ box-sizing : border-box;
4+ }
5+ body {
6+ background-color : rgb (70 , 70 , 94 );
7+ color : white;
8+ }
9+ section {
10+ margin : 150px auto;
11+ padding : 4rem ;
12+ width : 50% ;
13+ }
14+ legend {
15+ font-size : large;
16+ font-weight : bold;
17+ }
18+ # copy {
19+ background-color : rgb (166 , 250 , 166 );
20+ outline : none;
21+ cursor : pointer;
22+ border : none;
23+ padding : 1rem 2rem ;
24+ border-radius : .5rem ;
25+ }
26+ # coupon {
27+ outline : none;
28+ border : none;
29+ padding : 1rem 2rem ;
30+ border-radius : .5rem ;
31+ }
You can’t perform that action at this time.
0 commit comments