我正在使用SweetAlert Box,我有一个下拉列表,我需要动态地从代码中绑定下拉值,我正在生成值的代码' list'并将其设置为文本属性,但将其包装在引号中,我需要删除它以显示我的下拉列表值。它显示空列表,因为它的引号列在引号内。请帮忙
swal({
title: "",
text: 'Please select User'+
' <select id="ddlUser" >' +
list + // This list is a variable which has option values for dropdownlist
'</select> ',
html: true,
});
// list以这种形式包含此连接数据:
<option value= "1"> A </option><option value= "2"> B </option>
答案 0 :(得分:0)
您需要将双引号替换为实体表示"
list = '<option value="1"> Option 1 </option>';
list.replace(/"/g, '"');
swal({
title: "",
text: 'Please select User'+
' <select id="ddlUser" >' +
list +
'</select> ',
html: true
});