在th中显示图片

从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'));
        })
    });
原文地址:https://www.cnblogs.com/sunliyuan/p/8891426.html