Yui 脚本在YAHOO.util.Event.addListener处停止
我是YUI的新手。只是想在我的网站上找到一个最基本的功能示例 代码如下:Yui 脚本在YAHOO.util.Event.addListener处停止,yui,Yui,我是YUI的新手。只是想在我的网站上找到一个最基本的功能示例 代码如下: <button id="mytest">test</button> <script type="text/javascript"> var helloWorld = function(e) { alert("Hello World!"); } </script> <script type="t
<button id="mytest">test</button>
<script type="text/javascript">
var helloWorld = function(e) {
alert("Hello World!");
}
</script>
<script type="text/javascript">
alert('xx');
YAHOO.util.Event.addListener("mytest", "click", helloWorld);
alert('x2');
</script>
测试
var helloWorld=函数(e){
警报(“你好,世界!”);
}
警报(“xx”);
YAHOO.util.Event.addListener(“mytest”,“click”,helloWorld);
警报('x2');
xx警报显示,但x2警报从不显示。而且,单击按钮不会触发HelloWorld函数
我有必要的包括文件:
<!-- Required CSS -->
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.8.1/build/progressbar/assets/skins/sam/progressbar.css">
<!-- Dependency source file -->
<script src = "http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom.event.js" ></script>
<script src = "http://yui.yahooapis.com/2.8.1/build/element/element-min.js" ></script>
<!-- Optional dependency source file -->
<script src="http://yui.yahooapis.com/2.8.1/build/animation/animation-min.js" type="text/javascript"></script>
<!-- ProgressBar source file -->
<script src = "http://yui.yahooapis.com/2.8.1/build/progressbar/progressbar-min.js" ></script>
相信我找到了。或者至少我能找到其他有效的例子。但在我的例子中,我认为问题在于我引用的js文件实际上并不存在。即此文件:
您应该确保js文件包含在html文件中,您编写的代码是编写的 当然,这是yahoo dash dom dash事件,而不是yahoo dash dom DOT事件为了将来的参考,请学会使用并热爱Firefox的Firebug扩展。404和其他错误在“网络”选项卡中以红色显示,非常有用。:)是的,但是我看到了雅虎自己的“建议”,可以参考他们网站上的文件。