TAG
JavaScript
Result
Run
License
<h3>designMode</h3> <label> <input type="radio" name="designmode" value="off" checked /> off </label> <label> <input type="radio" name="designmode" value="on" /> on </label> <h1>designMode</h1> <output></output>
window.addEventListener("load", function() { const elRadio = document.querySelectorAll("input[name='designmode']"); elRadio.forEach(radio => radio.addEventListener("click", setDesignMode)); const elOutput = document.querySelector("output"); function setDesignMode(e) { const elTarget = e.currentTarget; if(elTarget.checked) { let designMode = elTarget.value; document.designMode = designMode; elOutput.textContent = `콘텐츠를 수정할 수 ${designMode == "off" ? '없다.' : '있다.'}`; } } let evtClick = new Event("click"); elRadio[0].dispatchEvent(evtClick); });
Console
expand_less
License
License
by DevDic
Close