如何在mvc视图中的html href内传递变量

我想传递动态 IMEI 号码,而不是静态 IMEI。我想通过

obj[i].DeviceImei

在 href 标签内 1009 处的 Google 地图标记信息窗口查看更多选项。

 var contentString = '<div id="content">' +
                                        '<div id="siteNotice">' +
                                        "</div>" +
                                        '<div id="bodyContent">' +
                                        "<p><b>Location: " + obj[i].location + "<br>"
                                        + "\n" +"IMEI: " + obj[i].DeviceImei +"<br>"
                                                                                                                 
                                        + "\n" + "PRV Trip: " + obj[i].PRV_T + "<br>"
                                        +'<a href="http://hostname/1009">' +
                                        "View More" +
                                        "</p>" +
                                        "</div>" +
                                        "</div>";


慕容708150
浏览 131回答 1
1回答

呼唤远方

您可以使用 来转义引号\",因此在您的情况下它将是:+'<a&nbsp;href=\"http://hostname/'&nbsp;+&nbsp;obj[i].PRV_T&nbsp;+&nbsp;'\">'&nbsp;+
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript