토글버튼 질문 드립니다. 채택완료
qogmlwo127
4년 전
조회 1,816
답변 3개
채택된 답변
+20 포인트
4년 전
원버튼
</p>
<p><button style=cursor:pointer onclick=toggle()>위젯바꾸기</button>
<div id="test1" class="h-full">1번위젯</div>
<div id="test2" class="h-full" style=display:none>2번위젯</div>
<script>
mode = true;
function toggle() {
if (mode) test1.style.display = 'none', test2.style.display = 'block'
else test1.style.display = 'block', test2.style.display = 'none';
mode = !mode
}
</script></p>
<p>
토글버튼
</p>
<p><button id=toggleBtn style=cursor:pointer onclick=toggle()>2번위젯</button>
<div id="test1" class="h-full">1번위젯</div>
<div id="test2" class="h-full" style=display:none>2번위젯</div>
<script>
mode = true;
function toggle() {
if (mode) test1.style.display = 'none', test2.style.display = 'block', toggleBtn.innerText = '1번위젯';
else test1.style.display = 'block', test2.style.display = 'none', toggleBtn.innerText = '2번위젯';
mode = !mode
}
</script></p>
<p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
q
qogmlwo127
4년 전
감사합니다!!!
댓글을 작성하려면 로그인이 필요합니다.
4년 전
</p>
<p><script></p>
<p> $(function() {
$('#test0').on('click', function() {
var status = $(this).data('status');
var state = $('#tes1').css('display');
if (status == 'none'||state == 'none') {
$(this).data('status', 'block');
$(this).text('test2');
$('#tes1').show();
$('#tes2').hide();
} else {
$(this).data('status', 'none');
$(this).text('test1');
$('#tes2').show();
$('#tes1').hide();
}
});
});</p>
<p></script></p>
<p>
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인