Home > Web Front-end > JS Tutorial > javascript inneHTML mine_javascript skills

javascript inneHTML mine_javascript skills

WBOY
Release: 2016-05-16 18:34:18
Original
1000 people have browsed it

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:

Copy the code The code is as follows:

var newTable = document.createElement('table');
document.body.appendChild(newTable);
var newTr = document.createElement('tr');
var rowContent = 'Situ ZhengmeiRestlessDream';
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!");
}


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

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 ZhengmeiRestlessDream

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 ; 🎜>



[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute ]
This solves the problem of firefox Condition!
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template