To review, IE will kill some of the blank space in front of the tag, capitalize all the tags inside it, and display dynamically added attributes. In some elements, it is still read-only. This thing invented by IE ended up with so many flaws, which is really chilling. However, innerHTML has another minefield, which exists in the most standard Firefox. Look at the following code:
var newTable = document.createElement('table');
document.body.appendChild(newTable);
var newTr = document.createElement('tr');
var rowContent = '
Situ Zhengmei | RestlessDream | ';
newTr.innerHTML = rowContent;
newTable.appendChild(newTr );
alert(newTable.innerHTML)
if (rowContent.toLowerCase() == newTr.innerHTML.toLowerCase()) {
alert("It must be as I wish!");
}else {
alert("You stepped on a thunder!");
}
]
When we add innerHTML to tr node, it will be parsed by Firefox into:
The code is as follows:
Situ Zhengmei< em>RestlessDream
instead of the original:
The code is as follows:
Situ Zhengmei | RestlessDream | The td tag has been removed! I think it is related to the order of adding the DOM tree. Adjust it:
The code is as follows:
var newTable = document.createElement('table');
document.body.appendChild(newTable);
var newTr = document.createElement('tr');
newTable.appendChild(newTr ; 🎜>
This solves the problem of firefox Condition!