我想将值传递给Javascript语句。可能吗? 例如:
function Show(msg, Id, Msgtype) { // I need to pass this Id argument to below javascript innerHtml statement
var strVar = "";
strVar = "Hello" + Msgtype + " <i class='icon-remove close'></i> " + msg + "</div>";
document.getElementById("???").innerHTML = strVar; // ??? should be the Id above in the function arguments
}
或者换句话说,我该如何实现这种情况?
答案 0 :(得分:4)
只需通过Id
,就像这样
document.getElementById(Id).innerHTML = strVar;