我正在生成动态 HTML,并希望将数组传递给调用函数。该数组也是动态生成的。
pinfoarray的内容有点像这样“冰球”,“少年篮球”,“女子足球”
var theHost = "<a href='#someDialog' onclick='chnghost(' + pinfoarray + ');' data-toggle='modal' class='button'>Change</a>";
如何才能将数组发送到调用函数而不出错。
最佳答案
如何制作它like this :
var anchor = document.createElement('a');
anchor.href = '#someDialog';
anchor.setAttribute('data-toggle','modal');
anchor.className='button';
anchor.onclick = function(){
chnghost(pinfoarray);
}
关于javascript - 在 Javascript 中将数组传递给函数并转义双引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23329492/