How do I create a globally accessible variable?

前端 未结 3 499
你的背包
你的背包 2021-01-25 03:28

I\'m trying to make a variable thats can work anywhere, and just not in one function.

How do i do this? I\'ve searched for like 1 hour now and i can\'t find it :(

<
3条回答
  •  一向
    一向 (楼主)
    2021-01-25 03:40

    you can always use the window object to attach your "global" variable, but not a very good idea, could cause collisions with other usages

    window.noneTxt = document.innerHTML="Nothing is playing!";
    

提交回复
热议问题