티스토리 뷰
[조건]
1. 버튼 클릭 시 url 이 복사됩니다.
2. 버튼 클릭하는동안 버튼의 배경색에 opacity가 들어가야합니다.
3. 복사와 함께 복사되었습니다. 라는 토스트 팝업이 잠시 나왔다가 사라집니다.
[html]
1. 링크복사 버튼은 css로 모양을 만들어줄 예정입니다.
2. 토스트 팝업은 잠시 숨겨둘 예정입니다.
<span class="shareLinkArea">
<input type="text" name="referralUrl" value="주소가들어갑니다" id="shareLink" readonly>
<span class="copyShareLink">링크복사</span>
</span>
<div class="toastPopup hide">
<p>링크가 복사되었습니다.</p>
</div>
[css]
1. 버튼<span>에 :active를 활용하여 클릭하는 동안 배경색에 opacity를 적용합니다.
* : active :: 마우스를 사용하는 경우, "활성"이란 보통 마우스 버튼을 누르는 순간부터 떼는 시점까지를 의미합니다.
[참고]
https://developer.mozilla.org/ko/docs/Web/CSS/:active
:active - CSS: Cascading Style Sheets | MDN
:active CSS 의사 클래스는 사용자가 활성화한 요소(버튼 등)를 나타냅니다.
developer.mozilla.org
.shareLinkArea input{
border: 1px solid #000000;
width: 210px;
height: 24px;
border-top-left-radius: 15px;
border-bottom-left-radius: 15px;
line-height: 24px;
padding-left: 15px;
background-color: #fffdee;
}
.shareLinkArea span{
display: inline-block;
height: 28px;
vertical-align: bottom;
margin-left: -4px;
cursor: pointer;
width: 60px;
background: #000;
color:#FFF400;
border-radius: 0 50px 50px 0;
text-align: center;
line-height: 28px;
font-weight: 400;
font-size: 12px;
}
.shareLinkArea span:active{
background: #000;
opacity: 0.5;
font-weight: 700;
}
.toastPopup {
width: 223px;
height: 38px;
background: #4f95d0;
border-radius: 4px;
position: absolute;
top: -35%;
left: 50%;
margin-left: -112px;
}
.toastPopup p{
font-size: 14px;
color:#fffdee;
line-height: 38px;
text-align: center;
}
.hide {
display : none;
}
[jQuery]
1 document.execCommand("copy")를 활용하여 url을 복사합니다.
[참고]
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
Interact with the clipboard - Mozilla | MDN
There are two ways browser extensions can interact with the system clipboard: the Document.execCommand() method and the modern asynchronous Clipboard API.
developer.mozilla.org
2. 팝업창을 fadeIn, fadeOut 을 활용해여 서서시 나타났다 사라지게 합니다.
* .fadeIn()은 선택한 요소를 서서히 나타나게 합니다.
* fadeOut()은 선택한 요소를 서서히 사라지게 합니다.
$('.copyShareLink').on('click', function () {
var copyShareLink = $('#shareLink');
copyShareLink.select();
document.execCommand("Copy");
$('.toastPopup').fadeIn(400).delay(400).fadeOut(400);
});'프론트엔드 > javaScript, jQuery' 카테고리의 다른 글
| [jQuery] 로그인 Form 구현하기 (0) | 2021.08.26 |
|---|---|
| [javaScript] EventListener 이용하여 button 기능 개발 (0) | 2021.08.25 |
| [jQuery] 높이에 따른 더보기 버튼 유무 (2) | 2021.08.17 |
| [javaScript] javaScript Drawing (0) | 2021.08.17 |
| [javaScript] function의 파라미터 사용하여 button기능 개발 (0) | 2021.08.17 |
- Total
- Today
- Yesterday
- CSS
- slick-slide
- jQuery
- paging-custom
- npm
- 퍼블리셔
- Portal
- React.js
- 로그인폼
- 탭메뉴
- 제이쿼리
- file-saver
- javascript
- 퍼블리싱
- 프론트엔드개발
- react
- 페이징 커스텀
- 슬릭 슬라이드
- excel down
- css3
- react excel 다운
- 리액트 포탈
- frontend
- 디자인시스템만들기
- HTML
- 프론트엔드
- excel custom
- 개발
- node.js
- react portal
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |