在th中显示图片
原创
©著作权归作者所有:来自51CTO博客作者zhangyongshizhi的原创作品,请联系作者获取转载授权,否则将追究法律责任
从DataTable中获取值:
foreach (DataRow dr in ((DataTable)ViewBag.bookInfoList).Rows)
{
<tr>
<th class="showImg" value="@dr["example"]"></th>
<th class="showImg">"@dr["answer"]"</th>
<th class="showImg" value="@dr["analysis"]"></th>
<th>@dr["keypoint"]</th>
<th>@dr["keypointTitle"]</th>
<th class="showImg" value="@dr["keypointContent"]"></th>
<th class="showImg" value="@dr["examples"]"></th>
}
循环显示:
$(function () {
$('.showImg').each(function (item, index) {
console.log($(this));
console.log(index);
$('.showImg').eq(item).html($('.showImg').eq(item).attr('value'));
})
});