【问题标题】:Creating Hyperlinks for Append(Response) Output为追加(响应)输出创建超链接
【发布时间】:2022-01-17 12:07:41
【问题描述】:

有人可以帮助我了解如何为 append(response) 的输出创建超链接。

    <script type="text/javascript">
$(document).ready(function () {
        $("#Sid").change(function () {
        if (document.getElementById("Sid").selectedIndex == 0) {
            $("#Did").empty();
        }
        else {
            var SitId = $(this).val();
            debugger
          $.ajax({
              type: "post",
              url: "/Dropdown/GetDeviceList?Sid=" + SitId,
                contentType: "html",
               success: function (response) {
                   debugger
                   $("#Did").empty();
                   $("#Did").append(response);

【问题讨论】:

  • 您应该包含一个示例来说明响应的外观。

标签: c# jquery asp.net-mvc


【解决方案1】:

如果响应是 url 字符串:

$("#Did").append(`<a href="${response}">link text</a>`)

【讨论】:

    猜你喜欢
    • 2014-03-02
    • 1970-01-01
    • 1970-01-01
    • 2016-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多