1
CSHTML代码:ASP.Net MVC - 获取选定<tr>行从表中通的jQuery
foreach (Frame frame in Model.ListFrames)
{
<tr class="clickME" title="fred">
<input type="hidden" name="NameId" value="@frame.Id" style="border:0"/>
<input type="hidden" name="TypeId" value="@frame.Type" />
<input type="hidden" name="thirdone" value="@frame.Id" />
<td>
<a href="#" class="up"><img src="../../Content/img/up.jpg" style="border:0px" alt="Move up" /></a>
<a href="#" class="down"><img src="../../Content/img/down.jpg" style="border:0px" alt="Move down"/></a>
</td>
@if(frame.Type == string.Empty)
{ <td>
<textarea rows="1" cols="15" id="Name" name="Name" onclick="display('@frame.Id', this); LoadImage(this);"
onchange="LoadImage(this);" onkeyup="LoadImage(this);" style="height:20px">@frame.Name</textarea>
</td>
<td>
@(Html.DropDownList("MyFont", new SelectList((IEnumerable)ViewData["Font"], "Text", "Value", @frame.Font),
new { onclick="LoadImage(this);", onchange = "LoadImage(this);" }))
</td>
<td>
@(Html.DropDownList("MyColor", new SelectList((IEnumerable)ViewData["Color"], "Text", "Value", @frame.Color),
new { onclick="LoadImage(this);" , onchange = "LoadImage(this);" }))
</td>
<td>
@(Html.Telerik().NumericTextBox()
.Name("onTime" + frame.Id)
.MinValue(0)
.Value(frame.OnTime)
.InputHtmlAttributes(new { style = "width:50px;" })
)
</td>
<td>
@(Html.DropDownList("onTransition"+frame.Id,
new SelectList((IEnumerable)ViewData["Transition"], "Value", "Text", @frame.Transition),
new {onclick="LoadImage(this);"})
)
</td>
}
else
{
<td colspan="3">
<textarea rows="1" cols="15" id="Name" name="Name" readonly="true" onclick="display('@frame.Id', this);" style="height:20px">@frame.Name</textarea>
</td>
<td style="display:none;">
@(Html.DropDownList("MyFont", new SelectList((IEnumerable)ViewData["Font"], "Text", "Value", @frame.Font),
new { onclick = "LoadImage(this);", onchange = "LoadImage(this);" }))
</td>
<td style="display:none;">
@(Html.DropDownList("MyColor", new SelectList((IEnumerable)ViewData["Color"], "Text", "Value", @frame.Color),
new { onclick = "LoadImage(this);", onchange = "LoadImage(this);" }))</td>
}
}
我试图获得直通一个jQuery命令当前所选行的frame.Id值。 我想让它在它自身之外。即当页面上的其他地方点击提交按钮时。我已经定义了以下功能:
$(".flashing").click(function() {
var tr = $(this).find(".clickME");
alert(tr.children.length);
});
这个作品 - 在这么多,因为我相信我找到我正确的标签,但不知道它是实际上当前选择与否的人。对于children.length,我总是得到2的值,但不确定它指向的是什么。
因此,在上述函数中是否有可能确定(最终)存储在当前选定标记中的@ frame.Id值。
我对此很陌生,而且这段代码已经被其他人编写了,所以我只是想找到自己的方式。
TIA
杰森
嗨达林 不幸的是,我得到一个“不确定”当我尝试用你有什么存在。我尝试了不同的.find排列('input也包含select,但它也不起作用 - 结果相同。移除.val()显示对象对象,所以我相信它找到了“某些东西”。虽然,米仍然不知道,如果我有多行如何可以找到当前的 - 或者它只是“知道”? 谢谢 – Jason 2011-04-27 08:35:35