【问题标题】:I am working on appending row in javascript but I actually don't know how to append an image in row cell我正在尝试在 javascript 中添加行,但实际上我不知道如何在行单元格中添加图像
【发布时间】:2021-02-28 13:45:47
【问题描述】:
 [I am appending a row. everything appended but image not showing. I tried some ways but cant solve this problem][1]
function SearchDrivers() {
        var Id = document.getElementById('driverSearch').value;
        $.ajax({
            url: "/Administration/SearchDrivers/" + Id,
            type: "Get",
            contentType: "application/json;charset=UTF-8",
            dataType: "json",
            success: function (response) {
                var table = document.getElementById('DriverTable');
                var drivers = response['users'];
                for (var j = 0; j <= drivers.length; j++) {
                    var driver = drivers[j];
                    tr = "<tr>"
                        + "<td>" + driver['email'] + "</td>"
                        + "<td>" + driver['email'] + "</td>"
                        + "<td>" + "033138445156666" + "</td>"
                        + "<td>" + "<button class='table-btn'>unverified</button>" + "</td>" 

这是我添加图像及其样式的方式。我使用了更多方法来附加图像,但它们也不适合我。

                        + "<td>" + "<a asp-action='DriverProfile'><img class='ml-2 icon-15' src='~/svg/visibility.svg'></a>" + "</td>"
                        + "</tr>";
                    $('#DriverTable tbody').append(tr);
                }



            }
            
        });
    }

【问题讨论】:

标签: javascript c# jquery asp.net-core row


【解决方案1】:

您的svg 文件夹应放在wwwroot.

那么你需要改变你的路径

<img class='ml-2 icon-15' src='/svg/visibility.svg'></a>

删除~

【讨论】:

  • 谢谢它的工作,但 Asp-action 不工作
  • javascripts中的asp-action无法识别,需要改成"&lt;a href=" + "your herf" + "&gt;" + "&lt;img class='ml-2 icon-15' src='/svg/visibility.svg'&gt;&gt;&lt;/a&gt;"
猜你喜欢
  • 2018-11-17
  • 1970-01-01
  • 1970-01-01
  • 2014-07-13
  • 2019-08-08
  • 2021-03-14
  • 1970-01-01
  • 2019-05-10
  • 2021-01-21
相关资源
最近更新 更多