MVC 中如何点击的一行获取此行某一列的值?
chirsty423 2011-09-29 03:23:38
<table class="table" width="100%" layouth="138">
<thead>
<tr>
<th>
状态
</th>
</tr>
</thead>
<tbody>
@foreach (var Storage in ViewBag.StorageList)
{
<tr onmousedown="showVaule()">
<td id="statusid">@Storage.STATUS
</td>
</tr>
}
</tbody>
</table>
==============================================
<script type="text/javascript">
function showTypeInfo() {
alert($("#statusid").val()); //没用呢?
}
</script>
...全文
393 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
眼镜凶 2011-09-29
  • 打赏
  • 举报
回复
你循环N次,但ID 只有一个
chirsty423 2011-09-29
  • 打赏
  • 举报
回复
text() 始终都是取的第一行的嘛?
眼镜凶 2011-09-29
  • 打赏
  • 举报
回复
搂住

我就少打个()
还要让我在发次贴 加上去呀
眼镜凶 2011-09-29
  • 打赏
  • 举报
回复
$("#statusid").text()
WIKESOFT 2011-09-29
  • 打赏
  • 举报
回复
我只是来打酱油
theks 2011-09-29
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 shenyuxinlei 的回复:]

你试试 text
$("#statusid").text
[/Quote]

是的,td应该用.text()或者.html()
theks 2011-09-29
  • 打赏
  • 举报
回复
id应该唯一。。

------------------------------------------------------------------------------
<table class="table" width="100%" layouth="138">
<thead>
<tr>
<th>
状态
</th>
</tr>
</thead>
<tbody>
@foreach (var Storage in ViewBag.StorageList)
{
<tr onmousedown="showVaule(this)">
<td>@Storage.STATUS
</td>
</tr>
}
</tbody>
</table>
==============================================
<script type="text/javascript">
function showTypeInfo(t) {
alert($(t).find("td").eq(0).val());
}
</script>
chirsty423 2011-09-29
  • 打赏
  • 举报
回复
弹出来的对话框很有喜感。。。#17楼的兄弟
你可以试试
眼镜凶 2011-09-29
  • 打赏
  • 举报
回复
你试试 text
$("#statusid").text
萧炎 2011-09-29
  • 打赏
  • 举报
回复
var Result=document.getelementByid("id值").value;
chirsty423 2011-09-29
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 wiki14 的回复:]
你这里循环遍历生成的<td>,id都一样的怎么获取。
[/Quote]

<tr onmousedown="showVaule()">
Tr不是有一个点击此行的事件吗?
chirsty423 2011-09-29
  • 打赏
  • 举报
回复
"#ShowIt" 是这个 = “”
眼镜凶 2011-09-29
  • 打赏
  • 举报
回复
<td id="qq">@Storage.STATUS</td>
string value=$("#qq").Val()


chirsty423 2011-09-29
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 shenyuxinlei 的回复:]
<td id="">@Storage.STATUS</td>
string value=$("#<%=控件的客户端名%>").Val()
[/Quote]
我也实验过了,可是没用
<td id ="ShowIt">@Storage.STATUS</td>
$("#statusid").val() = "" 的
wiki14 2011-09-29
  • 打赏
  • 举报
回复
你这里循环遍历生成的<td>,id都一样的怎么获取。
眼镜凶 2011-09-29
  • 打赏
  • 举报
回复
<td id="">@Storage.STATUS</td>
string value=$("#<%=控件的客户端名%>").Val()

chirsty423 2011-09-29
  • 打赏
  • 举报
回复
没有控件啊。。。就是<td>@Storage.STATUS</td>

我就是想
alert(Storage.STATUS) 好纠结啊
眼镜凶 2011-09-29
  • 打赏
  • 举报
回复
string value=$("#控件的客户端名").Val()
chirsty423 2011-09-29
  • 打赏
  • 举报
回复
不是吧?那么麻烦 我看不看这个值无所谓,关键是程序自己看
chirsty423 2011-09-29
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lovesongforever 的回复:]
JQuery选择器取
[/Quote]
怎么取?
加载更多回复(5)

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧