标签: jquery global-variables
如何在jquery函数中更改全局变量。如果我使用下面的代码,它将显示“0”而不是“15”。
<script type> theValue=0; $(document).ready(function(){ theValue=15; }); </script> <script type="text/javascript"> document.write(theValue) </script>
答案 0 :(得分:2)
那是因为当你写作时,(文件).ready还没有被解雇。 Example, 注意它写0但是当你点击按钮15时。