storing the accessor to innerHtml as a var
I was trying to figure out a way to do the following
var foo = document.body.innerHtml;
then call foo = "testing"
and the body's html would read "testing"
but so far all that happens is innerHtml is returning the value of innerHtml ... which is expected
is there any way to store innerHtml and maybe do something like
var hold = "innerHtml"
document.body[hold] = "foo" &l开发者_如何学运维t;--- this does not work by the way
You will have to use innerHTML
(uppercase) instead of innerHtml
to get the desired results.
These lines produce the same results:
document.body.innerHTML;
document.body["innerHTML"];
document["body"].innerHTML;
document["body"]["innerHTML"];
精彩评论