class TimeInput extends HTMLElement {
connectedCallback(){
let sele = document.createElement('select');
sele.setAttribute('class', 'xxx');
sele.setAttribute('name', 'aaa');
this.appendChild(sele)
let opt= document.createElement('option');
for(var i=0; i<24; i++){
let opt= document.createElement('option');
opt.value = String(i).padStart(2, 0);
opt.text = String(i).padStart(2, 0)+'시';
sele.appendChild(opt)
}
}
}
customElements.define('time-input', TimeInput)
이런식으로 커스텀 한 후 <time-input></time-input>을 해놓으면
<select class="xx" name="aa"/> ... 이 만들어지는 것은 알았습니다. 그러면 저 for문 안에서 option에 삼항연산자 자체를 붙이려고한다면 어떻게 해야하나요? 최종적으로 <option (abc==ex ? 'selected' : '') />를 구현하고 싶습니다