Console access to Javascript variables local to the $(document).ready function

后端 未结 8 1183
盖世英雄少女心
盖世英雄少女心 2021-01-03 23:27

How can I access some variables inside

$(document).ready(function(){
    var foo=0;
    var bar = 3;
});

from Google chrome console? If I

8条回答
  •  借酒劲吻你
    2021-01-03 23:40

    $(document).ready(function(){
        window.foo=0;
        window.bar = 3;
    });
    

    You expose those vars into global scope(really not advised)

提交回复
热议问题