<!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" />
<script src="jquery-1.5.min.js" type="text/javascript"></script>
<script>
$(function(){
$(".edit").live("click",function(){
var tr = $(this).closest("tr");
var p = tr.data("obj");
$("#Title").val(p.Title);
$("#Content").val(p.Content);
$("#AddTime").val(p.AddTime);
$("#Add_Info").val("修改");
})
})
</script>
<title>无标题文档</title>
</head><body><table style="width: 836px">
<tr>
<th>标题</th>
<th>内容</th>
<th>添加时间</th>
</tr>
<tr>
<td><a href="ShowPage.aspx?128">13</a></td>
<td>123123</td>
<td>123456</td>
<td><a href="javascript:void(0)" class="edit">编辑</a> <a href="javascript:void(0)" class="delete">删除</a></td>
</tr>
</table> <table>
<tr>
<td>标题</td>
<td><input type="text" id="Title" /></td>
</tr>
<tr>
<td>内容</td>
<td><input type="text" id="Content" /></td>
</tr>
<tr>
<td>添加时间</td>
<td><input type="text" id="AddTime" /></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="添加" id="Add_Info" /><input type="button" value = "提交"/></td>
</tr>
</table></body>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.5.min.js" type="text/javascript"></script>
<script>
$(function(){
$(".edit").live("click",function(){
var tr = $(this).closest("tr");
var p = tr.data("obj");
$("#Title").val(p.Title);
$("#Content").val(p.Content);
$("#AddTime").val(p.AddTime);
$("#Add_Info").val("修改");
})
})
</script>
<title>无标题文档</title>
</head><body><table style="width: 836px">
<tr>
<th>标题</th>
<th>内容</th>
<th>添加时间</th>
</tr>
<tr>
<td><a href="ShowPage.aspx?128">13</a></td>
<td>123123</td>
<td>123456</td>
<td><a href="javascript:void(0)" class="edit">编辑</a> <a href="javascript:void(0)" class="delete">删除</a></td>
</tr>
</table> <table>
<tr>
<td>标题</td>
<td><input type="text" id="Title" /></td>
</tr>
<tr>
<td>内容</td>
<td><input type="text" id="Content" /></td>
</tr>
<tr>
<td>添加时间</td>
<td><input type="text" id="AddTime" /></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="添加" id="Add_Info" /><input type="button" value = "提交"/></td>
</tr>
</table></body>
</body>
</html>
解决方案 »
- document.createElement("script")创建的脚本在本地能正确执行,放到服务器上就没反应
- 我这样获取iframe中的信息,但是提示有问题
- 实际数组?实际数组?实际数组?实际数组?实际数组?实际数组?
- 怎么样禁止工具栏,F5,标题栏,总之一切跟刷新有关的东西
- textarea问题
- 100分求助!!!得到下面字符串中所有图片的src的属性值
- 我的javascript代码怎么不起作用啊?请高人指点。
- document.write()能不能在现有的表单中插一个文本框啊?
- 在jsp页面中的java脚本<% %>取得一字符串v1, 在javascript中用 var vName = <%= v1%>给vName赋值, 结果总是报语法错, 应该如何赋值呢,
- 在js里new数组怎么做?
- jquery默认的提示信息如何alert出来
- 推荐20款网站测试工具
$(function(){
$(".edit").live("click",function(){
var tr = $(this).closest("tr");
var p= tr.find("td");
$("#Title").val(p.eq(0).text());
$("#Content").val(p.eq(1).text());
$("#AddTime").val(p.eq(2).text());
$("#Add_Info").val("修改");
})
})改了下 能用 。
$("#Add_Info[value='修改']").live("click",function(){//Add_Info value的click事件
//you code
})也就是取值赋值了 。主要是弄个东西保存触发'编辑'的行 在集合中的下标 。就这么多了 。
var index = tr.parent().children().index( $(this).parent().parent());这样能获得是哪个行 。$(this)是个'编辑'a标签 。
<!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" />
<script src="jquery-1.4.4.js" type="text/javascript"></script>
<script>
$(function(){
$(".edit").live("click",function(){
var tr = $(this).parents("tr");
var p = tr.find("td");
$("#Title").val(p.eq(0).text());
$("#Content").val(p.eq(1).text());
$("#AddTime").val(p.eq(2).text());
$("#Add_Info").val("修改");});$("#Add_Info").click(function(){
var title=$("#Title").val();
var content=$("#Content").val();
var addTime=$("#AddTime").val();
var target=$(this).parents("table").prev().find("tr:eq(1)");
target.find("td").eq(0).text(title);
target.find("td").eq(1).text(content);
target.find("td").eq(2).text(addTime);
});})
</script>
<title>无标题文档</title>
</head><body><table style="width: 836px">
<tr>
<th>标题</th>
<th>内容</th>
<th>添加时间</th>
</tr>
<tr>
<td><a href="ShowPage.aspx?128">13</a></td>
<td>123123</td>
<td>123456</td>
<td><a href="javascript:void(0)" class="edit">编辑</a> <a href="javascript:void(0)" class="delete">删除</a></td>
</tr>
</table> <table>
<tr>
<td>标题</td>
<td><input type="text" id="Title" /></td>
</tr>
<tr>
<td>内容</td>
<td><input type="text" id="Content" /></td>
</tr>
<tr>
<td>添加时间</td>
<td><input type="text" id="AddTime" /></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="添加" id="Add_Info" /><input type="button" value = "提交"/></td>
</tr>
</table></body>
</body>
</html>