CSS checked 상태에 따라 display ON/OFF

sookyeong·2022년 3월 30일
0

checked 상태에 따라 display ON/OFF

HTML

<input type="checkbox" id="other" onclick="tool_other()" value="other">
<label for="other"></label>

<div id="other_text" style="display: none;"><input type="text" placeholder="선택지에 없으나 다룰 줄 아는 툴을 적어주세요."></div>

Javascript

function tool_other() {
    other = document.getElementById('other').checked;
    if (other) {
        document.getElementById('other_text').style.display = "block";
    } else {
        document.getElementById('other_text').style.display = "none";
    }
}

결과

profile
actions speak louder than words

0개의 댓글