Anchor标记的onclick未在jsfiddle中执行简单的jQuery函数 [英] Anchor tag's onclick isn't executing a simple jQuery function in jsfiddle

查看:71
本文介绍了Anchor标记的onclick未在jsfiddle中执行简单的jQuery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注在线jQuery教程,但无法在jsfiddle中使用此标记:

I'm following an online jQuery tutorial, and I'm unable to get this markup to work in jsfiddle:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script>
function ShowBox()
{
        $("#divTestArea1").fadeIn();
}
</script>
</head>

<div id="divTestArea1" style="padding: 50px; background-color: #89BC38; text-align: center; display: none;">
        <b>Hello, world!</b>
</div>

<a href="javascript:void(0);" onclick="ShowBox();">Show box</a>

</html>

这是无法使用的jsfiddle版本: fadeIn测试小提琴

Here's the jsfiddle version that isn't working: fadeIn test fiddle

单击超链接时应触发onclick事件,该超链接应调用ShowBox函数. ShowBox应该"fadeIn()"显示:none div,ID#divTestArea1.我究竟做错了什么?

The onclick event should fire when the hyperlink is clicked, which should call the ShowBox function. ShowBox should "fadeIn()" the display:none div, id #divTestArea1. What am I doing wrong?

谢谢!

推荐答案

像这样包装后,其工作原理:

After wrapping it like this its working:

<script type="text/javascript">
function ShowBox()
{
        $("#divTestArea1").fadeIn();
}
</script>

工作场所

这篇关于Anchor标记的onclick未在jsfiddle中执行简单的jQuery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆