<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("span[id^='reply']").click(function(){
$(this).next(".af").fadeIn('slow')
})
$(".add").click(function(){
var at=$(".replyContent").each(function(){
var x=$(this).val();
$("#show").text(x);
})
})
})
</script>
</head>
<body>
<div style=" border:#39F 1px solid; height:20px;" id="show"></div>
<div id="container">
<?php
for($i=0;$i<3;$i++)
{
?>
<div style=" border-bottom:#CCC 1px solid; margin: 0 auto;">
<div>
<?=$i?>
</div>
<div></div>
</span> <span class="reply" id="reply<?=$i?>"><a href="#" >回复</a></span>
<div style="display:none;" class="af">
<form>
<textarea style="width:200px;height:50px; margin:3px 0 0 60px; border:#C90 1px solid;" name="replyContent" class="replyContent"></textarea>
<div style=" margin-left:150px; margin-top:10px;">
<input value="提交" type="submit" style="padding:2px; border:#C60 1px solid;" class="add" />
</div>
</form>
</div>
</div>
<?
}
?>
</div>
<!--end#container-->
</body>
</html>问题:在"<div style=" border:#39F 1px solid; height:20px;" id="show"></div>"中不能显示输入文本框的内容 原因我找到了 就是each函数捣的乱 循环以后后面的空值把前面的值给覆盖了 怎样才能避免这种现象并把文本框中的值在div中show出来?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("span[id^='reply']").click(function(){
$(this).next(".af").fadeIn('slow')
})
$(".add").click(function(){
var at=$(".replyContent").each(function(){
var x=$(this).val();
$("#show").text(x);
})
})
})
</script>
</head>
<body>
<div style=" border:#39F 1px solid; height:20px;" id="show"></div>
<div id="container">
<?php
for($i=0;$i<3;$i++)
{
?>
<div style=" border-bottom:#CCC 1px solid; margin: 0 auto;">
<div>
<?=$i?>
</div>
<div></div>
</span> <span class="reply" id="reply<?=$i?>"><a href="#" >回复</a></span>
<div style="display:none;" class="af">
<form>
<textarea style="width:200px;height:50px; margin:3px 0 0 60px; border:#C90 1px solid;" name="replyContent" class="replyContent"></textarea>
<div style=" margin-left:150px; margin-top:10px;">
<input value="提交" type="submit" style="padding:2px; border:#C60 1px solid;" class="add" />
</div>
</form>
</div>
</div>
<?
}
?>
</div>
<!--end#container-->
</body>
</html>问题:在"<div style=" border:#39F 1px solid; height:20px;" id="show"></div>"中不能显示输入文本框的内容 原因我找到了 就是each函数捣的乱 循环以后后面的空值把前面的值给覆盖了 怎样才能避免这种现象并把文本框中的值在div中show出来?
</span> <span class="reply" id="reply<?=$i?>"><a href="#" >回复</a></span>
代码中标注红色的span只有结束标签,没找到与之匹配的开始标签,神马意思?
$("#show").html($(this).parent().prev().val());
});
input.add是submit类型的,点击后把文本控件的值赋给#show以后,表单就以GET方式提交到本页面了。