I have this code:
htmlStr+="<div class='list-group-item Specification' " +
"onClick=displayResults(" + key + ", '" + time +
"', '" + fieldevents +
"')>";
In Chrome debugger it generates the html I want, where
onclick=displayResults(1, '14:03', 'shotput, highjump, longjump')>
but in the elements tab I see that the generated html is
"onclick=displayResults(1," '14:03',
...where does the double quote after the first comma come from? I am using chrome btw
When an attribute value contains spaces, it needs to be enclosed in quotes. Otherwise, the space ends the value.
htmlStr+="<div class='list-group-item Specification' " +
"onClick=\"displayResults(" + key + ", '" + time +
"', '" + fieldevents +
"')\">";
Check out the below code:
htmlStr += "<div class='list-group-item Specification'
onClick='displayResults(" + key + ", '" + time + "', '" + fieldevents + "');'>";
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.