html - String with whitespace in javascript -


i have string "magic word". need use value in html checkbox generated javascript.

in javascript

var itemvalue= "magic task"; var opt = "<input type='checkbox' name='test' id='test' value="+ itemvalue+ "/>"+itemvalue+ "<br />"; alert(opt);  $(optiondiv).append(opt); 

in alert displaying actual value after submitting form getting first word value.it ignoring second word.

thanks ravi kant

you need wrap value single quotes:

"<input type='checkbox' name='test' id='test' value='" + itemvalue + "' />" 

Comments

Popular posts from this blog

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -