체크 박스는 클릭박스 소스로 넣고 싶어요
본문
체크 박스를 클릭박스로 만들고 싶어요
하나는 체크 하면 기존에 체크된거는 풀리는것도요
맨처음에는 1000에 체크 되어 있고
5000에 체크 하면 처음 체크된 금액은 풀리고 5000에 체크 변경되게요
<input type='checkbox' name='' id='bet_point' value='1000' checked>1000
<input type='checkbox' name='' id='bet_point' value='5000'>5000
<input type='checkbox' name='' id='bet_point' value='10000' >10000
<input type='checkbox' name='' id='bet_point' value='30000'>30000
<input type='checkbox' name='' id='bet_point' value='50000' >50000
<input type='checkbox' name='' id='bet_point' value='100000'>100000
답변 3
1. id 를 class 로 바꾸고
id='bet_point' -> class='bet_point'
2. jquery 로 이벤트 처리를 해주세요.
$(".bet_point").click(function(){
$(".bet_point").prop("checked", false);
$(this).attr('checked', 'checked');
});
또는
$(".bet_point").click(function(){
$(".bet_point").removeAttr('checked');
$(this).attr('checked', 'checked');
});
input type='radio' 사용하시면 될 것 같습니다
<input type="radio" id="apple" name="fruit" value="apple" checked>
<label for="apple">apple</label><br>
<input type="radio" id="banana" name="fruit" value="banana">
<label for="banana">banana</label><br>
<input type="radio" id="tomato" name="fruit" value="tomato">
<label for="tomato">tomato</label>
https://stackoverflow.com/questions/4697941/jquery-make-checkboxes-act-like-radio-buttons
https://www.tutorialsmade.com/make-checkboxes-act-like-radio-buttons-using-jquery/
참고하세요.
답변을 작성하시기 전에 로그인 해주세요.