<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" src="jquery-1.3.1.js" type="text/javascript">
$("#test").click(function(){alert("您点击了文字");});
</script>
</head>
<body>
<p id="test">你好</p>
</body>
</html>
我点你好俩字啥怎么啥反应都没有呢
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" src="jquery-1.3.1.js" type="text/javascript">
$("#test").click(function(){alert("您点击了文字");});
</script>
</head>
<body>
<p id="test">你好</p>
</body>
</html>
我点你好俩字啥怎么啥反应都没有呢
$("#test").click(function(){alert("您点击了文字");});
</script>改成
<script language="javascript" src="jquery-1.3.1.js" type="text/javascript"></script>
<script language="javascript">
$("#test").click(function(){alert("您点击了文字");});
</script>不能既加载src又写代码
$("#test").click(function(){alert("您点击了文字");});
});
要在dom加载完执行
<script type="text/javascript">
$("#test").click(function(){alert("您点击了文字");});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#test").click(function(){alert("您点击了文字");});
});
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
$("#test").click(function(){alert("您点击了文字");});
</script>
</head>
<body>
<p id="test">你好</p>
</body>
</html>
还是不对呀
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#test").click(function(){alert("您点击了文字");});
});
</script>
</head>
<body>
<p id="test">你好</p>
</body>
</html>