I have a script as follows where element is a number:
function updateList(element) {
var out_list = "<Select name='item" + element + "' onchange=getQualType(this.value, 'qualType" + element + "')>";
.... add options here ...
out_list += "</Select>"
document.getElementById('dropdown_list' + element).innerHTML = out_list;
}
However what is in the browser is:
<select name="item40" onchange="getQualType(this.value," 'qualtype40')="">
</script>
Can anyone point out what is causing the incorrect quotes in the output?
UPDATE
Spotted it:
var out_list = "<Select name='item" + element + "' onchange=getQualType(this.value, 'qualType" + element + "')'>";
Single quote after bracket - thanks all.
您可以尝试一下,在转义引号时遇到了问题:
var out_list = '<select name="item' + element + '" onchange="getQualType(this.value, \'qualType' + element + '\')">';
I would start by quoting the onChange
. If you don't do it, the browser makes its own decisions:
var out_list = "<Select name='item" + element + "' onchange=\"getQualType(this.value, 'qualType" + element + "');\">";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.