首页 > 解决方案 > 如何在表格中搜索 HTML img 标题属性?

问题描述

我有一个像图像中的表格。

** 第 1、第 2 和第 3 列搜索栏是可操作的。我的AssignedUser列由图像及其标题(用户名)组成,当您将光标移到它们上方时会出现这些标题。如何修复此列中的搜索栏?

这是我在第一、第二和第三列中搜索时使用的 Javascript 代码;**

var column = $(this);
$('#userList1 thead tr').clone(true).appendTo('#userList1 thead');
$('#userList1 thead tr:eq(1) th').each(function (i) {
    var title = $(this).text();
    var thID = $(this).attr('id');

  
    if (thID != "nosearch"/* && thID != "selectoption"*/) {
        $(this).html('<input type="text" placeholder="Search " id="searchbox"/>');

        $('input', this).on('keyup change', function () {
            if (table.column(i).search() !== this.value) {
                table
                    .column(i)
                    .search(this.value)
                    .draw();
            }
        });
    }

我的img标签如下;

if (item.AssignedUserPhoto != "") {
    <img id="profilePhotoimg" name="@item.AssignedUserID" src="@item.AssignedUserPhoto" value="@item.ID" title="@item.AssignedUserNAme")" />
}

标签: javascripthtmljquery.net

解决方案


推荐阅读