-5
<HTML>
<head>
<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">    </script>
</head>

<BODY>
<script type="text/javascript">
$(document).ready(function(){   

    $('#shareButton').click(function(){
        alert ("this is hit");
    });
});


</script>
<button id="shareButton" > Share </button>
</BODY>

</HTML>

单击按钮时,它不会提醒消息“This is Hit”。

请帮忙..谢谢

4

6 回答 6

3

将您的按钮移出<script>标签。

于 2012-07-23T07:04:01.433 回答
2

<button id="shareButton" > Share </button><script>标签中删除。

于 2012-07-23T07:03:31.870 回答
1

移动<script>标签的按钮。因为按钮标签在脚本标签内,它应该在外面。

于 2012-07-23T07:07:39.300 回答
0

您的按钮元素位于<script>标签内。将它放在脚本部分之前或之后。

于 2012-07-23T07:04:41.060 回答
0

按钮标签在脚本标签内,它应该在外面。

于 2012-07-23T07:04:49.000 回答
0
hi there but above code is working in on my side, 

我正在使用自行运行的 Firefox 13.0.1 浏览器代码。如果您看不到结果,请检查您包含的 jquery 文件是否正确,请检查您的互联网连接是否正常,以便将来自 google 的文件包含在您的 html 页面中。并将脚本放在 html 的 head 部分和 body 部分的按钮中

于 2012-07-23T07:27:32.437 回答