티스토리 뷰
WebPublisher/JavaScript & jQuery
[javaScript] click 요소 data value로 popup창 띄우기
amanda 2023. 12. 29. 15:06클릭한 요소의 데이터 값 가져와서 팝업 띄우기
HTML
<!-- button -->
<button type="button" class="btn_pop" data-target="pop_01">팝업열기</button>
<!-- // button -->
<!-- popup -->
<div id="dim"></div>
<div class="pop_container" id="pop_01">
<!-- popup head -->
<div class="pop_head">
<strong class="pop_tit">팝업 제목</strong>
<a href="#n" class="btn_pop_close" title="팝업 닫기">
<img src="./img/ico_close.png" alt="">
</a>
</div>
<!-- // popup head -->
<!-- popup contents -->
<div class="pop_contents">
팝업 내용
</div>
<!-- // popup contents -->
</div>
<!-- // popup -->
CSS
/* common */
html, body{margin: 0;padding: 0;}
/* popup */
#dim{display: none;position: fixed;top: 0;left: 0;z-index: 1;width: 100%;height: 100%;background-color: rgba(0,0,0,0.5);}
.pop_container{display: none;position: fixed;left: 50%;top: 50%;-webkit-transform: translate(-50%, -50%);transform: translate(-50%, -50%); z-index: 2;width: 90%;max-width: 500px;background-color: #fff;}
.pop_head{display: flex;justify-content: space-between;padding: 10px;background-color: #eee;}
.pop_head .pop_tit{font-size: 16px;font-weight: 700;}
.pop_contents{padding: 20px;}
javaScript
var dim = document.getElementById('dim');
var btnPop = document.querySelector('.btn_pop');
var btnPopClose = document.querySelector('.btn_pop_close');
var popUp = document.querySelector('.pop_container');
// popup open
btnPop.addEventListener('click', function(e){
var crtData = e.currentTarget.dataset.target;
var crtPop = document.querySelector('#' + crtData);
dim.style.display = 'block';
crtPop.style.display = 'block';
});
// popup close
btnPopClose.addEventListener('click', function(){
dim.style.display = 'none';
popUp.style.display = 'none';
})
'WebPublisher > JavaScript & jQuery' 카테고리의 다른 글
[javaScript] slot machine counting animation (0) | 2024.01.11 |
---|---|
[javaScript] counting flip animation (1) | 2024.01.11 |
[javaScript] chart 플러그인 (1) | 2023.12.27 |
[javaScript] countdown event (0) | 2023.12.13 |
[jQuery] 세로 방향 위로 올라가는 marquee (0) | 2023.12.13 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 이미지맵반응형
- flipanimation
- 퍼블리셔이직
- flipjavascriptanimation
- calendarflipanimation
- clockflipanimation
- 경력직웹퍼블리셔이직
- php조건문
- phpif조건문
- 2단레이아웃반응형
- a태그다운로드
- 스크롤커스텀
- marquee html
- 인쇄스크립트
- sticky제이쿼리
- calendarflipjavascript
- rwdImageMaps
- marquee javascript
- 텍스트플로팅효과
- 이미지onerror
- marquee css
- 자동인쇄script
- php조건문축약형
- flipjavascript
- 스티키효과
- 흘러가는텍스트효과
- 에러이미지속성
- 그리드반응형
- 스크롤커스텀css
- 에러이미지마크업
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함