This is a question I saw on the CSDN forum. I usually don't pay attention to it, or I don't use it in this way. Look at the code
]
Isn't that the expected result? The execution situation under Opera is also the same as that under Firefox. You can try to run it under Opera and you will understand.
What if we can get the results we expected? I tried to use the __defineGetter__ method to get all innerHTML under Mozilla, but here it gave me some tips. For example:
If you need to introduce external Js, you need to refresh to execute
]
[Ctrl A to select all Note:
If you need to introduce external Js, you need to refresh to execute
]
This method was successful, which means that innerHTML under Mozilla obtains its innerHTML by traversing the tagName and attrubutes of all nodes of the element. Therefore, the innerHTML in our first example cannot get the modified value.
<script>
var foo = function() {
var $ = function() { return document.getElementById(arguments[0]); }
$("d2").innerHTML = $("d1").innerHTML;
}
//]]>
</script>At the same time, this trick can also be used in Opera. It also proves that innerHTML under Opera also obtains its innerHTML by traversing the tagName and attrubutes of all nodes of the element. Is this the standard in w3c? I haven't had time to check the w3c information yet, so I can't say whether it's a coincidence between Opera and Mozilla, or whether it's a design that's more comfortable for developers under IE.