<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
</head>
<body>
<?phpfor($i=0;$i<5;$i++){
?>
<p>xxxxxx</p>
<span id="x">
<?=$i?>
</span> <span id="show"><a href="#">获取id</a></span>
<?
}
?>
<script>
$("#show").click(function(){
var n=$("#x").html();
alert(n);
})
</script>
</body>
</html>问题:只能获取第一条id 后面的都获取不到 求解?
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
</head>
<body>
<?phpfor($i=0;$i<5;$i++){
?>
<p>xxxxxx</p>
<span id="x">
<?=$i?>
</span> <span id="show"><a href="#">获取id</a></span>
<?
}
?>
<script>
$("#show").click(function(){
var n=$("#x").html();
alert(n);
})
</script>
</body>
</html>问题:只能获取第一条id 后面的都获取不到 求解?
解决方案 »
- 菜鸟问题???
- PHP 获取客户端信息的问题
- php中如何获取404页面的之前的那个url
- 正则表达式后向引用
- 求PHP网络编程标准教程的源代码
- Amfphp配置
- 如何判断数组里面有多少个相同元素?
- Notice:Array to string conversion
- mysql疑问:将表a中所有tid=5的数据插入到表b(两表结构相同),怎样写mysql语句?
- 请求能够过滤UBB代码和html代码的PHP或Javascript
- 使用php将数据写入mysql,但连接时没反应,没说连接成功也没说连接失败,会有哪些原因?
- 我在用PHP做上传头像。 在系统头像中选择头像后上传,(不是自己浏览头像的)。
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
</head>
<body>
<?phpfor($i=0;$i<5;$i++){
?>
<p>xxxxxx</p>
<span class="x<?=$i?>">
<?=$i?>
</span> <span class="show" id="x<?=$i?>"><a href="#">获取id</a></span>
<?
}
?>
<script>
$(".show").click(function(){
var n=$("."+this.id).html();
alert(n);
})
</script>
</body>
</html>
<? echo $i?>
这一段不太好理解 刚开始我就意识到要用this这个关键字 一般重复的要取到当前值必用this或$(this) 但我就是不知道怎么用