更新时间:2022-10-19 13:26:40
& quot ;
是正确的方式,您的三分之一的测试:
< option value =& ;asd> test< / option>
你可以看到这个工作在一个jsFiddle示例此处,或者,您可以使用单引号对属性值进行分隔:
< option value ='asd'> test< / option>
I have a drop down on a web page which is breaking when the value string contains a quote.
The value is "asd
but in the DOM always appears as an empty string.
I have tried every way I know to escape the string properly but to no avail.
<option value=""asd">test</option>
<option value="\"asd">test</option>
<option value=""asd">test</option>
<option value=""asd">test</option>
Any idea how to render this on the page so the postback message contains the correct value?
"
is the correct way, the third of your tests:
<option value=""asd">test</option>
You can see this working in a jsFiddle example here. Alternatively, you can delimit the attribute value with single quotes:
<option value='"asd'>test</option>