Contents

조회 수 5559 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

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/




?

  1. [ios] 기본 네비게이션바의 타이틀, back버튼 위치와 속성 변경

    Date2016.05.16 CategoryDevelop Byhooni Views5167
    Read More
  2. [ios] Pod 특정 버전 설치하고 사용하기

    Date2022.05.28 CategoryDevelop Byhooni Views5152
    Read More
  3. [ios] DatePicker iOS 6.x 이하 디자인.

    Date2014.04.10 CategoryDevelop Byhooni Views5113
    Read More
  4. [c] Mac OS 에 gmp(gmp.h) 라이브러리 설치

    Date2016.10.03 CategoryDevelop Byhooni Views5055
    Read More
  5. [ios] Xcode를 사용해서 Static Library 만들기 (시뮬레이터 + 디바이스)

    Date2015.01.03 CategoryDevelop Byhooni Views5050
    Read More
  6. [ios] 아이폰 GPS 사용하기

    Date2014.05.24 CategoryDevelop Byhooni Views5026
    Read More
  7. [android] 코드에서 문자열로 Resource 가져오기

    Date2015.07.09 CategoryDevelop Byhooni Views5001
    Read More
  8. [ios] 애플 앱스토어 IDFA 리뷰 정책 변경 안내

    Date2014.05.07 CategoryDevelop Byhooni Views4997
    Read More
  9. [ios] How to set up clang formatter

    Date2015.09.17 CategoryDevelop Byhooni Views4981
    Read More
  10. [ios] UDID 사용 제한에 따른 대안들

    Date2014.03.13 CategoryDevelop Byhooni Views4971
    Read More
  11. [ios] 앱 딜리게이트 얻어오기. (AppDelegate)

    Date2014.05.10 CategoryDevelop Byhooni Views4765
    Read More
  12. [matlab] ZigZag-Scanning (2-D Array)

    Date2016.10.15 CategoryDevelop Byhooni Views4760
    Read More
Board Pagination Prev 1 ... 52 53 54 55 56 57 58 59 60 61 ... 71 Next
/ 71