Test browsers: ie8 (compatible and incompatible modes), ff6.
var chk = document.createElement("input");
chk.setAttribute("type","checkbox");
container.appendChild(chk);
chk.setAttribute("checked",true);
Above The code does not always work in ie8 compatibility mode and ff6, but it does not work in ie8 incompatibility mode. It only works after appendChild and then setting the checked value, as follows:
var chk = document.createElement("input");
chk.setAttribute("type ","checkbox");
chk.setAttribute("checked",true);
container.appendChild(chk);
It seems that the above paragraph is reversed.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn