checkbox, button, input select
본문 바로가기

Frontend/dom

checkbox, button, input select

checkbox

<input type="radio" id="date" name="frequency" checked="checked" value="0" onclick = 'drawChart();'>
<label for="date">날짜별</label>
document.querySelector('input[name="frequency"]:checked').value

 

 

button

 

div

 

input

<input type="radio" id="date" name="frequency" checked="checked" value="0" onclick='drawChart();'>
<label for="date" class="color_box">날짜별</label>
document.querySelector('label[for = "date"]')

 

radio

테이블내 tr td속 라디오버튼을 추출하여 다른 tr td의 특정 값을 구하고자할때

1.미리 value에 특정값을 넣어줌

	<input type="radio" id='seeker_radio' name="choice_secial" value="ㅇㅇㅇ" checked>
    
    let checkedbox = document.querySelector('input:checked')
    checkedbox.value //'ooo' 숫자가아닌 문자열이므로 데이터넘겨줄때 주의

 

2. 정모를경우

	let checkedbox = document.querySelector('input:checked')
	let scenario_no = checkedbox.offsetParent.nextElementSibling.innerText;

 

반응형