I'm

Developer, Designer, Photographer

GET IN TOUCH

  • Buk-gu, Busan, Republic of Korea
  • ungdoli0916@naver.com
  • Kakao ID : Ungdoli
Your message has been sent. Thank you!
(즐거웅코드) 제이쿼리 show()/hide() 함수로 화면에서 숨기거나 보이게 하기

· 즐거'웅' 코드 (Source)/HTML & CSS & JAVASCRIPT
2020. 3. 26. 21:19

반응형
jQuery
1
2
3
4
5
6
7
8
9
<script>
    function test() {
        if ($('#(아이디명)').css('display'== 'block') {
            $('#(아이디명)').hide();
        } else {
            $('#(아이디명)').show();
        }
    }
</script>
예제 소스
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
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
  
<style>
    div {
        width: 200px;
        height: 50px;
        background-color: #414144;
    }
  
    button {
        width: 200px;
        height: 50px;
    }
</style>
  
<button onclick="test()"></button>
<div id="test_obj"></div>
  
<script>
    function test() {
        if ($('#test_obj').css('display'== 'block') {
            $('#test_obj').hide();
        } else {
            $('#test_obj').show();
        }
    }
</script>
구현 예시
반응형