开发者

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"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜