선택장애

check box 클릭시 이벤트 주기 ex) input box 값 바꾸기 본문

자바스크립트

check box 클릭시 이벤트 주기 ex) input box 값 바꾸기

yes or yes 2020. 9. 1. 14:57
반응형


1. 체크박스와 텍스트박스를 하나 만들어줍니다.

<input type="checkbox" name="offline" id="offline" value="1"/>

<input type="text" name="clean" id="clean"></div>

 

2. 이벤트를 넣어줍니다.

$(document).ready(function(){
$("#offline").change(function(){         
        if($("#offline").is(":checked")){
           $("#clean").val("클릭시 바뀌는 값이 나옵니다.");
        }
    });

});

반응형