Develop
2021.02.03 16:13
[js] show/hide 이벤트 감시 (Observing show/hide event)
조회 수 5570 댓글 0
Observing show/hide events with jQuery.
HTML Code
<button id="btnShow">Show</button>
<button id="btnHide">Hide</button>
<div class="container">
<div id="foo">
I am #foo
</div>
</div>
<div id="console">
</div>
CSS Code
.container {
height:60px;
margin:10px;
}
#foo {
background-color:#eeeeee;
width:150px;
height:50px;
text-align:center;
font-size:20px;
}
JQuery Code
//The magic code to add show/hide custom event triggers
(function ($) {
$.each(['show', 'hide'], function (i, ev) {
var el = $.fn[ev];
$.fn[ev] = function () {
this.trigger(ev);
return el.apply(this, arguments);
};
});
})(jQuery);
//on Show button click; show the #foo div
$('#btnShow').click(function(){
$('#foo').show();
});
//on Hide button click; hide the #foo div
$('#btnHide').click(function(){
$('#foo').hide();
});
//Add custom handler on show event and print message
$('#foo').on('show', function(){
$('#console').html( $('#console').html() + '#foo is now visible'+ '<br>' )
});
//Add custom handler on hide event and print message
$('#foo').on('hide', function(){
$('#console').html( $('#console').html() + '#foo is hidden'+ '<br>' )
});
[출처] https://www.viralpatel.net/jquery-trigger-custom-event-show-hide-element/
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
709 | Develop |
[ios] APNS 클라이언트 구현 (pdf)
![]() |
hooni | 2013.06.27 | 16994 |
708 | Develop | [ios] APNS, Remote Push 사용자가 수신을 동의했는지 확인하기 | hooni | 2018.10.19 | 3341 |
707 | Develop | [ios] APNS, Remote Push 수신 시점에서 앱의 3가지 실행 상태 | hooni | 2018.10.19 | 3127 |
706 | Develop |
[ios] APNS에 사용할 인증서 만들기 (KeyChain에 있는 인증서 Export)
![]() |
hooni | 2015.01.03 | 2149 |
705 | Develop |
[ios] App States
![]() |
hooni | 2013.07.22 | 14535 |
704 | Develop |
[ios] Background 에서 네트워크 사용
![]() |
hooni | 2013.07.22 | 13158 |
703 | Develop |
[ios] binary를 C코드로 변환
![]() |
hooni | 2015.01.03 | 3133 |
702 | Develop | [ios] CoreData 사용하기 (튜토리얼) | hooni | 2014.03.28 | 4319 |
701 | Develop | [ios] Crashlytics, Fabfic 설치/설정 | hooni | 2016.07.21 | 2367 |
700 | Develop |
[ios] DatePicker iOS 6.x 이하 디자인.
![]() |
hooni | 2014.04.10 | 5122 |
699 | Develop |
[ios] Debug Extensions (from 종길 차장님 ㅋㅋ)
![]() |
hooni | 2013.04.23 | 18908 |
698 | Develop | [ios] Did UIScrollView End Scrolling? | hooni | 2016.04.19 | 8344 |