0

我的 Javascript 用于点击

<script type="text/javascript">
$(document).ready(function () {
    $(".role").click(function () {
        alert("idiot");
    });
});  
</script>

我的 DIV“角色”的 CSS

{
position: absolute;
 width: 50px;
 min-height:20px;
 height:auto;
 border:1px solid #000; 
 word-wrap: break-word; 
 float:left;
 font-size:12px;
  z-index: 30;
  margin-top:50px;
  margin-left:3px;
}

这是 HTML

<div class="role" align="center"  >Gate Keeper</div>

如何调用HTML的点击函数?

这是我的小提琴

http://jsfiddle.net/6CWUq/

4

1 回答 1

6

您忘记在 jsfiddle 中包含 jQuery 框架。只需选择您想要包含的 jQuery 版本,您的代码就会按预期工作:

在此处输入图像描述

于 2013-06-16T08:02:44.753 回答