How set html attribute value by javascript? -


consider code:

<input type="1 == 1 ? 'radio' : 'checkbox'" value="myvalue"/> 

but renders text box input. seem javascript not set type value.

how set html attribute value javascript?

javascript engine doesn't interpret random html attributes source code. of course can't trying do. consider this:

<input type="text" value="myvalue"/>  <script>    var input = document.queryselector('input');    input.type = 1 == 1 ? 'radio' : 'checkbox'  </script>


Comments