Recent Posts
-
DOM 복사 & 삭제
1
html <a href="#" class="btn4" data-dom-class=".domEducation" data-dom-num="0">추가하기<i class="axi axi-plus"></i></a> <div class="form-align domEducation"> <a href="#" class="btn2 del" data-del-class=".domEducation">삭제</a> <dl class="item w16"> <dt>학교명 <em class="col">*</em></dt> <dd> <input type="text" placeholder="학교명을 입력해주세요."> </dd> </dl> <dl class="item w33"> <dt>재학기간 <em class="col">*</em></dt> <dd class="many-inputs"> <input type="text"> <em class="hipen">~</em> <input type="text"> </dd> </dl> </div> jquery // 복사 & 삭제 dom_add_del = { 'init' : function(){ this.action(); }, 'action' : function(){ //dom var dom_arr = [ '<div class="form-align domEducation"><a href="#" class="btn2 del" data-del-class=".domEducation">삭제</a><dl class="item w16"><dt>학교명 <em class="col">*</em></dt><dd><input type="text" placeholder="학교명을 입력해주세요."></dd></dl><dl class="item w33"><dt>재학기간 <em class="col">*</em></dt><dd class="many-inputs"><input type="text"><em class="hipen">~</em><input type="text"></dd></dl><dl class="item w16"><dt>전공 <em class="col">*</em></dt><dd><input type="text" placeholder="전공을 입력해주세요."></dd></dl><dl class="item w16"><dt>소재지 <em class="col">*</em></dt><dd><input type="text" placeholder="소재지를 입력해주세요."></dd></dl><dl class="item w16"><dt>비고</dt><dd><input type="text"></dd></dl></div>', 'html 작성해주세요', 'html 작성해주세요' ]; //add $('*[data-dom-class]').on({ 'click' : function(e){ e.preventDefault(); var cname = $(this).data('dom-class'); var num = $(this).data('dom-num'); $(cname).last().after(dom_arr[num]); } }) //del $(document).on('click', '*[data-del-class]', function(e){ e.preventDefault(); var cname = $(this).data('del-class'); $(this).closest(cname).remove(); }) } } dom_add_del.init();
-
input tag (속성:inputmode, pattern)
html <input type="text" inputmode="numeric" pattern="[0-9\-]*" placeholder="숫자와 하이픈 입력 가능"> 표현 예시 <input type="text" inputmode="numeric" pattern="\d*" placeholder="숫자만"> <input type="text" inputmode="numeric" pattern="[0-9]{6}" placeholder="생년월일 yymmdd"> <input type="text" inputmode="numeric" pattern="[a-zA-Z]*" placeholder="영문 대소문자만"> <input type="text" inputmode="numeric" pattern="[a-zA-Z\s]*" placeholder="영문 대소문자 공백"> <input type="text" inputmode="numeric" pattern="[a-zA-Z\s]*" placeholder="영문 대소문자 공백"> <input type="text" inputmode="numeric" pattern="(010)-\d{4}-\d{4}" placeholder="010-0000-0000">
-
MAC OS 에서만 CSS 파일 적용
Script <script type="text/javascript"> if( (navigator.userAgent).indexOf("Mac OS") > -1 ){//아이폰, 사파리가 해당됩니다. document.write('<link rel="stylesheet" href="/theme/wm-type1/css/global_macos.css?ver=asdas" />'); } </script> MAC OS 에서만 CSS 파일을 불러옵니다.
-
카카오맵 (마커, 오버레이, 부드럽게이동)
2
THML <ul class="fran-list"> <?php for ($i=0; $i < 3; $i++) { ?> <li> <a href="#" class="link"></a> <strong>충북1급자동차공업사</strong> <span class="add">충북 청주시 흥덕구 송절로 37</span> <span class="tel">00-000-0000</span> </li> <?php } ?> </ul> <div id="map"></div> <script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey=<?=$config_daum_map_key?>"></script> CSS #map {width:100%;height:650px;} .wrap {position: relative;z-index: 77;} .wrap .marker {border: 0px;padding: 0;background: none;margin: 0 auto;display: block;} .wrap .info {display: none;width: 280px;height: 130px;border-radius: 10px;padding: 17px 20px;border: 1px solid #ddd;background: #fff;position: absolute;bottom: 57px;left: 50%;transform: translateX(-50%);box-shadow: 0 0 15px rgba(0,0,0,0.2);box-sizing: border-box;} .wrap .info:after {display: block;content: '';width: 18px;height: 14px;position: absolute;top: 100%;left: 50%;transform: translateX(-50%);background: url('../images/main/overlay-box-arrow.png') no-repeat 50% 50%;background-size: contain;} .layOn {z-index: 78 !important;} .layOn > .wrap .info {display: block;} .info .close {position: absolute;top: 5px;right: 5px;font-size: 22px;color: #444;width: 30px;height: 30px;line-height: 30px;text-align: center;} .info .close:hover {cursor: pointer;} .info .tit {display: block;margin-bottom: 10px;font-size: 18px;color: #333333;font-weight: 700;letter-spacing: -0.05em;line-height: 30px;} .info .add, .info .tel {display: block;font-size: 15px;color: #666666;line-height: 26px;letter-spacing: -0.05em;padding-left: 22px;position: relative;background-repeat: no-repeat;background-position: 0 3px;} .info .add:before, .info .tel:before {display: block;font-family: 'axicon';font-size: 16px;color: #2f880e;position: absolute;top: 0;left: 0;} .info .add:before {content: '\e779';} .info .tel:before {content: '\e77d';} .fran-list li {position: relative;z-index: 0;} .fran-list li .link {position: absolute;top: 0;bottom: 0;left: 0;right: 0;z-index: 11;} javascript var mapContainer = document.getElementById('map'), // 지도의 중심좌표 mapOption = { center: new kakao.maps.LatLng(37.481510, 126.881393), // 지도의 중심좌표 level: 11 // 지도의 확대 레벨 }; var map = new kakao.maps.Map(mapContainer, mapOption); // 지도를 생성합니다 var markerImg = '/images/main/icon-marker.png'; // 마커를 표시할 위치와 title 객체 배열입니다 var positions = [ { title: '충북1급자동차공업사', add : '충북 청주시 흥덕구 송절로 37', tel : '043-263-4002', latlng: new kakao.maps.LatLng(37.481510, 126.881393), pos : [37.481510, 126.881393] }, { title: '충북1급자동차공업사2', add : '충북 청주시 흥덕구 송절로 37', tel : '02-523-2020', latlng: new kakao.maps.LatLng(37.841510, 126.881393), pos : [37.841510, 126.881393] }, { title: '충북1급자동차공업사3', add : '충북 청주시 흥덕구 송절로 37', tel : '02-523-2020', latlng: new kakao.maps.LatLng(37.481510, 126.818393), pos : [37.481510, 126.818393] }, ]; for (var i = 0; i < positions.length; i ++) { // 커스텀 오버레이에 표시할 컨텐츠 입니다 // 커스텀 오버레이는 아래와 같이 사용자가 자유롭게 컨텐츠를 구성하고 이벤트를 제어할 수 있기 때문에 // 별도의 이벤트 메소드를 제공하지 않습니다 var overlay = []; var content = '<div class="wrap lay'+i+'" data-num="'+i+'">' + ' <button type="button" class="marker"><img src="'+ markerImg +'" alt=""></button>' + ' <div class="info">' + ' <div class="close" title="닫기"><i class="axi axi-close"></i></div>' + ' <strong class="tit">'+ positions[i].title +'</strong>' + ' <p class="add">'+ positions[i].add +'</p>' + ' <p class="tel">'+ positions[i].tel +'</p>' + ' </div>' + '</div>'; // 마커 위에 커스텀오버레이를 표시합니다 // 마커를 중심으로 커스텀 오버레이를 표시하기위해 CSS를 이용해 위치를 설정했습니다 overlay[i] = new kakao.maps.CustomOverlay({ content: content, map: map, position: positions[i].latlng }); } //open function mapOpen(idxNum){ $('.lay'+idxNum).parent('div').addClass('layOn') .siblings().removeClass('layOn'); } //click on list function panTo(){ $('.fran-list .link').on({ 'click' : function(e){ e.preventDefault(); idxNum = $(this).parent('li').index(); // 이동할 위도 경도 위치를 생성합니다 var moveLatLon = positions[idxNum].latlng; // 지도 중심을 부드럽게 이동시킵니다 // 만약 이동할 거리가 지도 화면보다 크면 부드러운 효과 없이 이동합니다 map.panTo(moveLatLon); //open mapOpen(idxNum); } }) } panTo(); //overlay close function layClose(){ $(document).on('click', '.wrap .info .close', function(){ $(this).closest('.wrap').parent('div').removeClass('layOn'); }) } layClose(); //overlay open function layOpen(){ $('.wrap .marker').on({ 'click' : function(e){ idxNum = $(this).closest('.wrap').parent('div').index(); console.log(idxNum); // 이동할 위도 경도 위치를 생성합니다 var moveLatLon = positions[idxNum].latlng; // 지도 중심을 부드럽게 이동시킵니다 // 만약 이동할 거리가 지도 화면보다 크면 부드러운 효과 없이 이동합니다 map.panTo(moveLatLon); //open mapOpen(idxNum); } }) } layOpen();
-
input checkbox radio
html <div class="labskin"><input type="radio" name="_rad" id="_rad1_1"><label for="_rad1_1">KOR</label></div> css .labs {display: flex;flex-wrap: wrap;margin: -5px -10px;} .labs .labskin {margin: 5px 10px;} .labskin {position: relative;} .labskin input {position: absolute;top: 0;left: 0;opacity: 0;} .labskin label {font-size: 17px;color: #555555;letter-spacing: -1px;line-height: 22px;} .labskin input[type=checkbox] + label {padding-left: 20px;position: relative;} .labskin input[type=checkbox] + label:after {display: block;content: '';width: 15px;height: 15px;box-sizing: border-box;border: 1px solid #ccc;position: absolute;top: 50%;left: 0;transform: translateY(-50%);} .labskin input[type=checkbox]:checked + label:after {border-color: var(--color);content: '\e116';font-family: 'axicon';font-size: 12px;color: var(--color);text-align: center;line-height: 13px;text-indent: -1px;} .labskin input[type=radio] + label {padding-left: 20px;position: relative;} .labskin input[type=radio] + label:after {display: block;content: '';width: 15px;height: 15px;box-sizing: border-box;border: 1px solid #ccc;position: absolute;top: 50%;left: 0;transform: translateY(-50%);border-radius: 50%;} .labskin input[type=radio]:checked + label:after {border-color: var(--color);} .labskin input[type=radio]:checked + label:before {display: block;content: '';width: 7px;height: 7px;position: absolute;top: 50%;left: 4px;transform: translateY(-50%);border-radius: 50%;background: var(--color);}
-
레이어 드래그 앤 드롭
javascript window.onload = () => { $(init); function init() { $('#makeMeDraggable').draggable({ containment: '#content', cursor: 'move', snap: '#content' }); } };
-
[javascript] toggle 이벤트
javascript var btn_tog = document.getElementById("btn2"); btn_tog.addEventListener('click', () => { text_tog(); }); function text_tog(){ btn_tog.classList.toggle("on"); if(btn_tog.classList.contains("on")){ btn_tog.innerText = "처리중"; }else{ btn_tog.innerText = "완료"; } } 결과 화면 sample site 바로가기
-
[javascript] onclick 이벤트
javascript var ele_btn = document.getElementsByClassName("btn_cn")[0]; var ele_btn_qs = document.querySelector(".btn_qs"); var ele_btn_qsa = document.querySelector(".btn_qsa"); var ele_btn_reset = document.getElementById("btn_reset"); ele_btn.addEventListener('click', () => { ele_btn.innerText = ":::클릭했지롱~:::"; }); ele_btn_qs.addEventListener('click', () => { ele_btn_qs.innerText = ":::클릭했지롱~:::"; }); ele_btn_qsa.addEventListener('click', () => { ele_btn_qsa.innerText = ":::클릭했지롱~:::"; }); ele_btn_reset.addEventListener('click', () => { ele_btn.innerText = "버튼 클릭해줄래?"; ele_btn_qs.innerText = "선택자 querySelector로 적용"; ele_btn_qsa.innerText = "선택자 querySelectorAll로 적용"; }); 결과 화면 sample site 바로가기
-
[javascript] click 이벤트
javascript var btn_color = document.getElementById("btn1"); btn_color.addEventListener('click', () => { asd(); }); function asd(){ btn_color.style.background='red'; btn_color.style.color='white'; } 결과 화면 sample site 바로가기
-
[javascript] 이벤트 종류
javascript onclick : 마우스 왼쪽 클릭 ondbclick : 마우스 왼쪽 더블 클릭 onmousedown : 마우스 왼쪽 또는 오른쪽 클릭 ⇔ onmouseup : 마우스 왼쪽 또는 오른쪽 놓았을때 발생 onmouseover : mouseenter ⇔ onmouseout : mouseleave onchange : 요소 변경될 때 onselect : 값 선택되었을 때 onfocus : 포커스가 갔을 때 ⇔ onblur : 포커스를 잃었을 때
-
[javascript] 선택자 종류
javascript getElementById() getElementsByClassName() getElementByTagName() querySelector() querySelectorAll()
-
[javascript] 변수 & 상수
javascript const zzzz = '상수 const입니다.'; document.write('<p class="colBlue">' + zzzz + '</p>'); 결과 화면 변수 : 변경 가능 상수 : 변경 불가능 (재선언X) [변수] var : 어디서나 사용 가능 / 재선언 가능 [변수] let : 해당 scope(중괄호'{}' 안의 범위)에서만 사용 가능 / 재선언 불가 [상수] const : 해당 scope(중괄호'{}' 안의 범위)에서만 사용 가능 / 재선언 불가 sample site 바로가기
-
[javascript] 배열 Array
javascript var stit = ['제목1','제목2','제목3']; document.write('<p class="colBlue">2번째 값 : ' + stit[1] + '</p>'); 결과 화면 sample site 바로가기
-
[javascript] 데이터의 형태
javascript var val1 = 24; var val2 = '안녕'; var val3 = true; document.write('<p class="mt10 colBlue">숫자 : ' + typeof(val1) + '<br />문자 : ' + typeof(val2) + '<br />논리 : ' + typeof(val3) + '</p>'); 결과 화면 숫자 : number 문자 : string 논리 : boolean sample site 바로가기
-
[javascript] 변수 선언하기 (초기화)
javascript var eleName = '변수 이름'; var eleNumber = '1'; document.write('<p class="colBlue">' + eleName + ' / 번호:' + eleNumber + '</p>'); 결과 화면 sample site 바로가기
-
[javascript] 값 출력
javascript document.write('<p class="colBlue">안녕</p>'); 결과 화면 sample site 바로가기
-
html5 video tag 정지, 재생, 처음부터 재생 시키기
1
[사이트] 글 퍼왔습니다. jquery // slide 이동시 video 컨트롤 $ele.roll.on('afterChange', function(event, slick, currentSlide, nextSlide){ // video 요소를 만듬 var $video = $('#visual_video')[0]; // 동영상이 있는 슬라이드에 도달하면 동영상 첨부터 재생 (2번 슬라이드) if (currentSlide == 2) { $video.play(); // slick auto play 일시 중지함 // code ... } else { $video.pause(); $video.currentTime = 0; // slick auto play 재작동함 // code ... } }); html <video oncontextmenu="return false;" autoplay muted loop playsinline> <source src="<?=DIR?>/files/momt_video.mp4" type="video/mp4"> </video>
-
[Jquery] 특정 영역만 인쇄하기 - printThis
1
HTML <a href="#" id="btn_print">프린트하기</a> jquery // print $(document).ready(function() { $("#btn_print").click(function() { $("#prdt-view").printThis(); }); }); /* * printThis v2.0.0 * @desc Printing plug-in for jQuery * @author Jason Day * @author Samuel Rouse * * Resources (based on): * - jPrintArea: http://plugins.jquery.com/project/jPrintArea * - jqPrint: https://github.com/permanenttourist/jquery.jqprint * - Ben Nadal: http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm * * Licensed under the MIT licence: * http://www.opensource.org/licenses/mit-license.php * * (c) Jason Day 2015-2022 * * Usage: * * $("#mySelector").printThis({ * debug: false, // show the iframe for debugging * importCSS: true, // import parent page css * importStyle: true, // import style tags * printContainer: true, // grab outer container as well as the contents of the selector * loadCSS: "path/to/my.css", // path to additional css file - use an array [] for multiple * pageTitle: "", // add title to print page * removeInline: false, // remove all inline styles from print elements * removeInlineSelector: "body *", // custom selectors to filter inline styles. removeInline must be true * printDelay: 1000, // variable print delay * header: null, // prefix to html * footer: null, // postfix to html * base: false, // preserve the BASE tag, or accept a string for the URL * formValues: true, // preserve input/form values * canvas: true, // copy canvas elements * doctypeString: '...', // enter a different doctype for older markup * removeScripts: false, // remove script tags from print content * copyTagClasses: true // copy classes from the html & body tag * copyTagStyles: true, // copy styles from html & body tag (for CSS Variables) * beforePrintEvent: null, // callback function for printEvent in iframe * beforePrint: null, // function called before iframe is filled * afterPrint: null // function called before iframe is removed * }); * * Notes: * - the loadCSS will load additional CSS (with or without @media print) into the iframe, adjusting layout */ ; (function($) { function appendContent($el, content) { if (!content) return; // Simple test for a jQuery element $el.append(content.jquery ? content.clone() : content); } function appendBody($body, $element, opt) { // Clone for safety and convenience // Calls clone(withDataAndEvents = true) to copy form values. var $content = $element.clone(opt.formValues); if (opt.formValues) { // Copy original select and textarea values to their cloned counterpart // Makes up for inability to clone select and textarea values with clone(true) copyValues($element, $content, 'select, textarea'); } if (opt.removeScripts) { $content.find('script').remove(); } if (opt.printContainer) { // grab $.selector as container $content.appendTo($body); } else { // otherwise just print interior elements of container $content.each(function() { $(this).children().appendTo($body) }); } } // Copies values from origin to clone for passed in elementSelector function copyValues(origin, clone, elementSelector) { var $originalElements = origin.find(elementSelector); clone.find(elementSelector).each(function(index, item) { $(item).val($originalElements.eq(index).val()); }); } var opt; $.fn.printThis = function(options) { opt = $.extend({}, $.fn.printThis.defaults, options); var $element = this instanceof jQuery ? this : $(this); var strFrameName = "printThis-" + (new Date()).getTime(); if (window.location.hostname !== document.domain && navigator.userAgent.match(/msie/i)) { // Ugly IE hacks due to IE not inheriting document.domain from parent // checks if document.domain is set by comparing the host name against document.domain var iframeSrc = "javascript:document.write(\"<head><script>document.domain=\\\"" + document.domain + "\\\";</s" + "cript></head><body></body>\")"; var printI = document.createElement('iframe'); printI.name = "printIframe"; printI.id = strFrameName; printI.className = "MSIE"; document.body.appendChild(printI); printI.src = iframeSrc; } else { // other browsers inherit document.domain, and IE works if document.domain is not explicitly set var $frame = $("<iframe id='" + strFrameName + "' name='printIframe' />"); $frame.appendTo("body"); } var $iframe = $("#" + strFrameName); // show frame if in debug mode if (!opt.debug) $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-600px", top: "-600px" }); // before print callback if (typeof opt.beforePrint === "function") { opt.beforePrint(); } // $iframe.ready() and $iframe.load were inconsistent between browsers setTimeout(function() { // Add doctype to fix the style difference between printing and render function setDocType($iframe, doctype){ var win, doc; win = $iframe.get(0); win = win.contentWindow || win.contentDocument || win; doc = win.document || win.contentDocument || win; doc.open(); doc.write(doctype); doc.close(); &nbs···
-
[Jquery] 첨부파일 추가 삭제
HTML <div class="_fileWrap w100"> <div class="fileaddel"> <input type="file" placeholder="파일을 첨부해주세요."> <span class="btns"> <a href="#" data-fileadd="._fileWrap"><i class="axi axi-plus-circle"></i> 파일 추가</a><hr /> <a href="#" data-filedel="._fileWrap">파일 삭제</a> </span> </div> </div> CSS .fileaddel {width: calc(265px + 145px + 20px);position: relative;display: flex;justify-content: space-between;align-items: center;} .fileaddel .btns {display: flex;align-items: center;} .fileaddel .btns a {color: #444444;letter-spacing: -1px;} .fileaddel .btns a i {display: inline-block;vertical-align: -2px;font-size: 18px;color: #999999;} .fileaddel .btns hr {border: 0;padding: 0;margin: 0 13px;width: 1px;height: 10px;background: #bbb;} jquery //file add & del fileaddel = { 'init' : function(){ this.action(); }, 'action' : function(){ var $ele = { 'add' : '*[data-fileadd]', 'del' : '*[data-filedel]' } $(document).on('click', $ele.add, function(e){ e.preventDefault(); var $wrap = $(this).data('fileadd'); var $ele = $($wrap).last().clone(); // console.log($ele); $($wrap).last().after($ele); }) $(document).on('click', $ele.del, function(e){ e.preventDefault(); var $wrap = $(this).data('filedel'); $(this).closest($wrap).remove(); }) } } $(function(){ if($('*[data-fileadd]').length>0){ fileaddel.init(); } })
-
[Jquery] 화면 아래로 내려갔을때 class 추가
HTML <div id="fast-inquiry-form"> <div class="wrap"> <form action="#"> <fieldset class="inr"> <legend>창업문의</legend> <div class="tit"> <img src="<?=DIR?>/images/main/fast-inquiry-logo.png" alt=""> <p>가맹문의</p> <a href="tel:<?=$config_tel[0]?>"><?=$config_tel[0]?></a> </div> <div class="boxs"> <input type="text" class="inp" placeholder="성함"> <input type="text" class="inp" placeholder="연락처(’-’ 제외)"> <select class="sel"> <option value="">창업희망지역 선택</option> </select> </div> <div class="agree"> <input type="checkbox" id="_agree" name="_agree"> <label for="_agree">개인정보수집 동의</label> <a href="#" data-pop-href="<?=SUBPAGE?>/popup/private" data-pop-chain="pop1" data-pop-size="500,650">[확인]</a> </div> <input type="submit" value="문의하기" class="sbm"> </fieldset> </form> </div> </div> CSS #fast-inquiry-form {height: 100px;position: relative;z-index: 77;} #fast-inquiry-form legend {display: none;} #fast-inquiry-form .wrap {position: absolute;bottom: 0;left: 0;right: 0;height: 100px;background: var(--color);} #fast-inquiry-form .wrap .inr {height: 100px;display: flex;align-items: center;justify-content: space-between;max-width: 1400px;margin: 0 auto;} #fast-inquiry-form .tit {position: relative;padding-left: 75px;} #fast-inquiry-form .tit > img {position: absolute;bottom: 0;left: 0;} #fast-inquiry-form .tit > * {display: block;} #fast-inquiry-form .tit > p {font-size: 20px;color: #111111;font-weight: 800;line-height: 23px;} #fast-inquiry-form .tit > a {font-size: 32px;color: #111111;font-weight: 700;font-family: 'WAGURI';line-height: 35px;} #fast-inquiry-form .boxs {display: flex;align-items: center;} #fast-inquiry-form .boxs .inp, #fast-inquiry-form .boxs .sel {background: #fff;border: 0px;margin-right: 5px;padding: 0 20px;width: 220px;height: 55px;font-size: 18px;color: #777;box-sizing: border-box;} #fast-inquiry-form .boxs .sel option {color: #777;} #fast-inquiry-form .boxs .inp {padding-left: 20px;color: #111;} #fast-inquiry-form .boxs .inp::-webkit-input-placeholder{color: #777;} #fast-inquiry-form .boxs .inp:-moz-placeholder{color: #777;} #fast-inquiry-form .boxs .inp::-moz-placeholder{color: #777;} #fast-inquiry-form .boxs .inp:-ms-input-placeholder{color: #777;} #fast-inquiry-form .agree {display: flex;align-items: center;position: relative;z-index: 0;} #fast-inquiry-form .agree input {position: absolute;top: 0;left: 0;width: 0;height: 0;opacity: 0;overflow: hidden;} #fast-inquiry-form .agree a {font-weight: normal;font-size: 18px;color: #111;letter-spacing: -1px;line-height: 22px;font-weight: 500;text-decoration: none !important;} #fast-inquiry-form .agree label {font-weight: normal;font-size: 18px;color: #111;letter-spacing: -1px;line-height: 22px;font-weight: 700;margin-right: 5px;} #fast-inquiry-form .agree input + label {padding-left: 30px;position: relative;z-index: 0;} #fast-inquiry-form .agree input + label:after {display: block;content: '';position: absolute;top: -1px;left: 0;width: 24px;height: 24px;border-radius: 50%;border: 2px solid #111;box-sizing: border-box;} #fast-inquiry-form .agree input:checked + label:after {content: '\e116';font-family: 'axicon';font-size: 14px;color: #fff;background-color: #111;line-height: 20px;text-align: center;} #fast-inquiry-form .sbm {border: 0px;background: var(--color-red);width: 160px;height: 55px;font-weight: normal;font-size: 21px;color: #fff;font-weight: 700;} #fast-inquiry-form.fix .wrap {position: fixed;z-index: 55;} jquery //Bottom Fixed botFix = { 'init' : function(){ this.action(); }, 'action' : function(){ var $ele = { 'foot' : $('#footer'), 'wrap' : $('#fast-inquiry-form') } var classFix = function(){ var wt = $(window).scrollTop(); var wh = $(window).height(); var tt = $ele.foot.offset().top; if(wt < tt - wh){ $ele.wrap.addClass('fix'); }else{ $ele.wrap.removeClass('fix'); } } $(window).on({ 'load scroll' : function(){ classFix(); } }); } } $(function(){ if($('#fast-inquiry-form').length>0){ botFix.init(); } }) 참고사이트 : 노랑강정
-
[Jquery] 숫자 효과
1
jQuery <script type="text/javascript"> $(function(){ var loop = 0 $(window).on({ 'scroll load' : function(){ var st = parseInt($(window).scrollTop()); var pos = $('._counter').offset().top - ($(window).height() / 2); if(st >= pos && loop==0){ $("._counter strong").each(function(i){ $(this).flipping_text({ tickerTime: 30, tickerCount: 15, customRandomChar: "1234567890" }); }) loop++; } } }) }) </script> /* jQuery Plugin : counter number */ !function(e){function r(e,t){var n,r,i=t;this.pause=function(){window.clearTimeout(n);i-=new Date-r};this.resume=function(){r=new Date;n=window.setTimeout(e,i)};this.resume()}var t={tickerTime:10,customRandomChar:false,tickerCount:10,opacityEffect:true,resetOnChange:false};var n=false;e.fn.flipping_text=function(i){var s=this;resetAll=function(t){t.each(function(t){e(this).css({opacity:1,visibility:"visible"}).text(e(this).data("ft-text"))})};return this.each(function(o){function c(){var e=f.text(),t=0;if(a.customRandomChar!=false){var i=a.customRandomChar}else{var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}f.attr("data-ft-text",e).html("");for(var s=0;s<l;s++){f.append("<span data-ft-bk='"+e.charAt(s)+"' class='ft_char"+s+"'></span>");var o=new r(function(){t=t+1;var e=0;if(n==true){return false}else{for(var s=0;s<a.tickerCount;s++){var o=f.find(".ft_char"+(t-1));var u=new r(function(){if(n==true){return false}else{if(e==a.tickerCount-2){o.css("opacity","1").text(o.data("ft-bk"));return false}else{if(a.opacityEffect==true){var t=e/a.tickerCount}else{var t=1}o.css("opacity",t).text(i.charAt(Math.floor(Math.random()*i.length)));e++}}},s*a.tickerTime)}}},(s+1)*a.tickerTime*a.tickerCount)}}if(e(this).data("delay")!==undefined){var u=e(this).data("delay")+0}else{var u=0}var a=e.extend({},t,i),f=e(this),l=f.text().length;if(a.resetOnChange==true){e(window).on("blur",function(){n=true;resetAll(s)})}f.css("visibility","hidden");var h=new r(function(){if(n==true){return false}else{f.css("visibility","visible");c()}},u*o)})}}(window.jQuery)
-
다차원 배열
<?php $_data = array( array( '제목1', '부제목1', '내용1' ), array( '제목2', '부제목2', '내용2' ), array( '제목3', '부제목3', '내용3' ) ); for ($i=0; $i < count($_data); $i++) { ?> <li> <?php if($_data[$i][0]){ ?><strong><?=$_data[$i][0]?></strong><?php } ?> <?php if($_data[$i][1]){ ?><span><?=$_data[$i][1]?></span><?php } ?> <?php if($_data[$i][2]){ ?><p><?=$_data[$i][2]?></p><?php } ?> </li> <?php } ?> <?php $_data = [ [ 't1' => '제목1', 't2' => '내용1' ], [ 't1' => '제목2', 't2' => '내용2' ], [ 't1' => '제목3', 't2' => '내용3' ] ]; for ($i=0; $i < count($_data); $i++) { ?> <li> <strong><?=$_data[$i][t1]?></strong> <p><?=$_data[$i][t2]?></p> </li> <?php } ?>
-
[Jquery] fullpage
2
fullpage 사용 방법 적용된 사이트 URL : 에이치케이세미텍 *2.9.7버전까지 무료 사용가능 HTML <div id="fullpage"> <article class="section visual"> <!-- visual ( type1: 위치 / type2: 이미지,동영상구분 ) --> <div class="roll"> <?php $main_banner_sql = banner_print('main_KOR', 'I', 500); while($main_banner_row = sql_fetch_array($main_banner_sql)){ ?> <div class="item"> <a href="<?=$main_banner_row['wm_link']?>" target="<?=$main_banner_row['wm_link_target']?>" style="background-image: url(<?=SP_DATA_URL?>/banner/<?=$main_banner_row['wm_upfile_name']?>);"> <img src="<?=SP_DATA_URL?>/banner/<?=$main_banner_row['wm_upfile_mo_name']?>" /> </a> </div> <?php } ?> </div> <div class="vis-control"> <button type="button" class="stop"><img src="/images/main/vis-stop.png" alt="stop"></button> <button type="button" class="play" style="display: none;"><img src="/images/main/vis-play.png" alt="play"></button> <button type="button" class="prev"><img src="/images/main/vis-prev.png" alt="prev"></button> <p class="vis-dots"> <span class="now">01</span>/<span class="tot">03</span> </p> <button type="button" class="next"><img src="/images/main/vis-next.png" alt="next"></button> </div> </article> <article class="section partners"> <div class="mtit"> <h3>partners</h3> </div> </article> <article class="section newsandnotice"> <div class="mtit"> <h3>newsandnotice</h3> </div> </article> <article class="section contactus"> <div class="mtit"> <h3>contactus</h3> </div> </article> <article class="section foot fp-auto-height"> <!-- s:footer --> <?php include PATH."/inc/foot.php"; ?> <!-- e:footer --> </article> </div> <!-- s:aside --> <aside id="aside"> <a href="#visual" data-menuanchor="visual">Main</a> <a href="#partners" data-menuanchor="partners">Partners</a> <a href="#newsandnotice" data-menuanchor="newsandnotice">News & Notice</a> <a href="#contactus" data-menuanchor="contactus">Contact us</a> <!-- <a href="#foot">foot</a> --> </aside> <!-- e:aside --> CSS #header {position: fixed;top: 0;left: 0;right: 0;height: 100px;background: rgba(0,0,0,0);background: #fff;} #aside {position: fixed;top: 50%;right: 80px;transform: translateY(-50%);display: flex;flex-direction: column;align-items: end;} #aside > a {margin: 9px 0;display: flex;align-items: center;position: relative;font-family: 'empty';font-size: 0;color: var(--color);font-weight: 700;} #aside > a:before {display: block;content: '';width: 7px;height: 7px;border-radius: 50%;background: #aaa;position: absolute;top: 12px;right: 12px;} #aside > a:after {opacity: 0;display: block;content: '';width: 32px;height: 32px;box-sizing: border-box;border-radius: 50%;border: 2px solid var(--color);margin-left: 12px;} #aside > a.active {font-family: 'Montserrat';font-size: 16px;} #aside > a.active:after {opacity: 1;} #aside > a.active:before {width: 10px;height: 10px;top: 11px;right: 11px;background: var(--color);} #fullpage .section {background: #444;} #fullpage .section:nth-child(odd) {background: #f1f1f1;} #fullpage .section:not(.foot, .visual) {padding-top: 100px;} #fullpage .section:not(.foot, .visual) .fp-tableCell {display: flex;justify-content: center;align-items: center;} #fullpage .section:not(.foot, .visual) .mtit > h3 {font-size: 42px;color: #fff;} #fullpage .section:nth-child(odd):not(.foot, .visual) .mtit > h3 {color: #222;} #main .visual{position: relative;} #main .visual .roll .item{position: relative;overflow: hidden;} #main .visual .roll .item a {display: block;height: 100vh;background-repeat: no-repeat;background-position: 50%;background-size: cover;} #main .visual .roll .item img{display: none;width: 100%;opacity: 0;} #main .visual .vis-control {position: absolute;bottom: 50px;left: calc(50% - 650px);display: flex;align-items: center;} #main .visual .vis-control * {color: #fff;} #main .visual .vis-control button {border: 0px;background: none;} jQuery // visual visual = { 'init' : function(){ this.action(); }, 'action' : function(){ var $ele = { 'roll' : $('.visual .roll') } var rolling = function(){ //item total number var tot_len = $('.visual .item').length; if (tot_len < 10) { tot_len = '0' + tot_len; } //10 이하 번호앞에 텍스트 0 입력 $('.visual .vis-dots .tot').text(tot_len); //slider $ele.roll.slick({ 'fade' : true, //Fade 롤링 효과 'dots' : false, //하단 pager 'arrows' : false, //next,prev 버튼 'infinite' : true, //무한반복 'slidesToShow' : 1, //슬라이드 갯수 'slidesToScroll' : 1, //롤링시 슬라이드 갯수 'autoplay' : true, //자동롤링 'autoplaySpeed' : 4000, //자동롤링 딜레이 'swipe' : false, //모바일 스와프 여부 'centerMode' : false, //Center모드. 가운데 slide에 'slick-active' 클래스 부여. 'centerPadding' : 0, //Center모드인 경우 좌/우 여백 설정 'vertical' : false, //vertical 모드 'zIndex' : 80, //z-index 'responsive' : [ //tablet { 'breakpoint' : 1300, 'settings' : { 'swipe' : true } } ] }); //현재 슬라이드 number $ele.roll.on('afterChange', function(event, slick, currentSlide, nextSlide){ now_len = currentSlide + 1; if (now_len < 1···
-
D-day 날짜
PHP <?php $endDate = date('2022-12-25'); //디데이 날짜 $Dday = floor(( strtotime(substr($endDate,0,10)) - strtotime(date('Y-m-d')) )/86400); if($Dday < 0){ $Dday = '00'; //D-Day 가 -로 넘어 갔을때 00으로 맞춤 } //echo 'D-'.$Dday; ?> HTML <?=$Dday?>
-
[Jquery] 이미지맵 반응형
2
jquery $(document).ready(function(){ //이미지맵이 있는 경우 반응형 이미지맵 처리 var coords = new Array(); function imagemap_coords(type){ $('area[coords2]').each(function(idx){ if(type=='ready'){ coords[idx] = $(this).attr('coords'); } var map_id = $(this).parent('map').attr('name'); var $img = $('img[usemap="#'+map_id+'"]'); var org_width = parseInt($img[0].naturalWidth); var now_width = $img.width(); var coords2 = coords[idx].split(','); var coords_re = ''; for(var i=0;i<coords2.length;i++){ coords_re += ','+coords2[i]*(now_width/org_width); } coords_re = coords_re.substring(1); $(this).attr('coords',coords_re); }); } imagemap_coords('ready'); $(window).resize(imagemap_coords); }); * 맵 api를 사용하는 경우 usemap 문제 발생할 수 있음. * 그런 경우 area 에 attribute 추가해서 사용할 것
-
[Jquery] 입력한 글자 수 체크
jquery // 입력한 글자수 체크 $('#content1').keyup(function (e){ var content = $(this).val(); $('#bytes1').html(content.length);//글자수 실시간 카운팅 if (content.length > 500){ alert("최대 1000자까지 입력 가능합니다."); $(this).val(content.substring(0, 500)); $('#bytes1').html("500"); } }); $('#content1').trigger('keyup');
-
[Jquery] 즐겨찾기 버튼
HTML <a calss="btn1" id="favorite">즐겨찾기</a> jquery //즐겨찾기 $(document).ready(function() { $(document).on('click', '#favorite', function(e) { var bookmarkURL = window.location.href; var bookmarkTitle = document.title; var triggerDefault = false; if (window.sidebar && window.sidebar.addPanel) { // Firefox version < 23 window.sidebar.addPanel(bookmarkTitle, bookmarkURL, ''); } else if ((window.sidebar && (navigator.userAgent.toLowerCase().indexOf('firefox') > -1)) || (window.opera && window.print)) { // Firefox version >= 23 and Opera Hotlist var $this = $(this); $this.attr('href', bookmarkURL); $this.attr('title', bookmarkTitle); $this.attr('rel', 'sidebar'); $this.off(e); triggerDefault = true; } else if (window.external && ('AddFavorite' in window.external)) { // IE Favorite window.external.AddFavorite(bookmarkURL, bookmarkTitle); } else { // WebKit - Safari/Chrome alert((navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Cmd' : 'Ctrl') + '+D 키를 눌러 즐겨찾기에 등록하실 수 있습니다.'); } return triggerDefault; }); });
-
[Jquery] 스크롤 시 해당 영역에 class 추가
CSS @media screen and (min-width: 1300px){ /* action */ #main-group .tt > * {opacity: 0;top: -50px;} #main-group.active .tt > * {opacity: 1;top: 0;} #main-group.active .tt > h3 {transition: all 0.5s 0s;} #main-group.active .tt > p {transition: all 0.5s 0.5s;} #main-group.active .tt > span {transition: all 0.5s 1s;} #main-group.active .tt > a {transition: all 0.5s 1.5s;} } jquery //scroll section active section_active = { 'init' : function(){ this.action(); }, 'action' : function(){ var $ele = { 'ani' : $('._ani'), 'win' : $(window), } $ele.win.on('load scroll', function(){ $ele.ani.each(function(i){ if( ( $ele.win.scrollTop() + ($ele.win.height() / 2) ) > $ele.ani.eq(i).offset().top ){ $(this).addClass('active'); }else{ $(this).removeClass('active'); } }); }); } } $(function(){ if($('#main ._ani').length>0){ section_active.init(); } }) 참고 사이트 : 저스트그룹
-
[Jquery] header 상단에서만 특정 class 추가
jquery //header bg headBg = { 'init' : function(){ this.action(); }, 'action' : function(){ var $ele = { 'win' : $(window), 'hd' : $('#header') } $ele.win.on({ 'scroll resize load' : function(){ var wt = $ele.win.scrollTop(); var hh = $ele.hd.height(); //console.log(wt); if(wt > hh){ $ele.hd.addClass('fix'); } else { $ele.hd.removeClass('fix'); } } }); } } $(function(){ if($('#header').length>0){ headBg.init(); } })
-
[Jquery] 메뉴 버튼 클릭 시 특정 위치로 스크롤 이동
HTML <ul id="gnb"> <li class="first"><a href="#">main</a></li> <li><a href="#">menu1</a></li> <li><a href="#">menu2</a></li> </ul> </ul> <div id="landing"> <article class="section visual"> <div class="mtit"> <h3>visual</h3> </div> </article> <article class="section menu1"> <div class="mtit"> <h3>‘menu1</h3> </div> </article> <article class="menu2"> <div class="mtit"> <h3>menu2</h3> </div> </article> </div> CSS #landing .section {min-height: 100vh;display: flex;justify-content: center;align-items: center;} #landing .section:nth-child(even) {background: #333;} #landing .section:nth-child(even) .mtit > h3 {color: #fff;} .mtit {display: flex;justify-content: center;align-items: center;flex-direction: column;} .mtit > * {display: block;text-align: center;} .mtit > h3 {font-size: 32px;line-height: 42px;color: #333;font-weight: 700;} Jquery //section target section_target = { 'init' : function(){ this.action(); }, 'action' : function(){ //aside Active 처리 var $ele = { 'win' : $(window), 'sec' : $('#landing .section'), 'btnWrap' : $('#gnb'), 'btnOn' : $('#gnb > li'), 'btn' : '#gnb > li > a', } var wh = []; var secNum = 0; $ele.sec.each(function(i){ wh[i] = $ele.sec.eq(i).offset().top; }); $(document).on('click', $ele.btn, function(e){ var i = $(this).parent('li').index(); var pos = $('.section').eq(i).offset().top; e.preventDefault(); $('html,body').animate({ 'scrollTop' : pos },600,'easeInOutQuart'); return false; }); function acc(){ $ele.btnOn.eq(secNum).addClass('active').siblings().removeClass('active'); if(secNum==0){ $ele.btnWrap.addClass('home-on'); }else{ $ele.btnWrap.removeClass('home-on'); } } acc(); $ele.win.on({ 'load scroll resize' : function(){ var sh = parseInt($(this).scrollTop()); for (i=0; i < $ele.sec.length; i++){ if(sh >= parseInt(wh[i]) - ($ele.win.height()/2)){ secNum = i; acc(); } } } }); } } $(function(){ $(window).on({ 'load' : function(){ if($('#landing .section').length>0){ section_target.init(); } } }); }) 참고 사이트 : 노랑강정