oct 05
Bueno algo tan simple y liviano como sería realizar esta acción desde Javascript se puede complicar si estamos trabajando con Internet Explorer y el elemento no pertenece al DOM.
Por ejemplo, queremos añadir un CheckBox a la página y establecer su valor a checked. Pues bien, si hacemos esto de la siguiente manera, no funciona:
JavaScript:
-
var chk = document.createElement("INPUT");
-
chk.setAttribute("type", "CHECKBOX");
-
chk.setAttribute("checked", "checked");
-
td.appendChild(chk);
En cambio si añadimos el objeto al DOM y posteriormente le establecemos el marcado, funciona correctamente.
JavaScript:
-
var chk = document.createElement("INPUT");
-
chk.setAttribute("type", "CHECKBOX");
-
td.appendChild(chk);
-
chk.setAttribute("checked", "checked");
Siempre nuestro amigo IE.......
Recent Comments