【发布时间】:2012-03-10 09:13:02
【问题描述】:
我创建了一个加载 .js 文档的文档,该文档具有我创建的一些 JQuery 函数。我想使用 firebug 控制台在我的 html 文档上快速测试这些函数的功能。但是当我尝试在控制台中调用这些函数时,我没有得到任何响应。
例如:
-
我有 index.html 调用我的 JS:
<script src="jquery.js" type"text/javascript"></script> <script src="myfunctions.js" type="text/javascript"></script> -
Myfunctions.js 中定义了以下内容:
function showAbout(){ $('div#about').show("slow"); $('.navbar #about-button').attr('disabled', true); }
问题:
当我尝试从 index.html 上的控制台调用 showAbout 或 showAbout() 时,我没有得到任何更改。但是,当我直接从控制台调用 $('div#about').show("slow"); 或 $('div#about').show("slow"); 时,我得到了预期的行为。
从控制台调用用户定义函数的正确方法是什么?
【问题讨论】:
标签: javascript jquery function console firebug