Skip to content Skip to sidebar Skip to footer

Input.setAttribute('type', 'checkbox'); IE Bug

This problem shows only in ie.all other browser namely ff,chrome,safari,opera works well. It doesn't show chcekbox instead shows a value box... code: &l

Solution 1:

You can't change the type attribute of an <input> or <button> after adding it to the DOM in IE, so change it before appending it, like this:

input.setAttribute("name", "friend");
input.setAttribute("type", "checkbox");
input.setAttribute("value", "yap frnd");
input.setAttribute("id", "xyz");
li1.appendChild(input);                 //this needs to happen after

Solution 2:

try:

input.setAttribute('type', 'checkbox');
                    ^

Notice the lowercase t.


Solution 3:

Since IE doesn't support a change in an input type once it has been assigned, you should assign the type before adding it to the DOM.


Post a Comment for "Input.setAttribute('type', 'checkbox'); IE Bug"