我使用WebGrid来填充像这样的信息
<div id="interiorGrid">
@{
var interiorList = Model.Lists;
var interiorGrid = new WebGrid(interiorList,
columnNames: new[] { "FeatureValue"},
canSort: false); }
@interiorGrid.GetHtml(
tableStyle: "table table-striped table-hover",
columns: interiorGrid.Columns(
interiorGrid.Column("IsActive", header: "",
format: @<text>
<img id="@item.ID" src=@if (item.IsActive == true){@("../../Images/Active.png");}
else{@("../../Images/InActive.png");}
onclick="return toggle('@item.ID'); return false;" /></text>),
interiorGrid.Column("FeatureValue", header: "",
format: @<text><span id='featureValue'>@item.FeatureValue</span></text>)))
</div>
这样可以很好地填充数据,页面中的HTML代码就像:
<div id="interiorGrid">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">
</th>
<th scope="col">
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<img id="312864" src=../../Images/InActive.png onclick="return toggle('312864'); return false;" /></td>
<td><span id='featureValue'>Daytime Running Lamps</span></td>
</tr>
------------MULTIPLE---------------------------
<tr>
<td>
<img id="312870" src=../../Images/Active.png onclick="return toggle('312870'); return false;" /></td>
<td><span id='featureValue'>Wipers, front intermittent</span></td>
</tr>
</tbody>
</table>
</div>
============= 我试图循环这个,并得到每个跨度文本。我正在尝试这样的代码,但是无法正常工作:
var gridData = $('#interiorGrid table tr').each(function () {
alert($(this).find('featureValue').text());
});
答案 0 :(得分:0)
您不需要#来识别Id
alert($(this).find('#featureValue').text());