How do I properly escape quotes inside HTML attributes?

前端 未结 6 950
遇见更好的自我
遇见更好的自我 2020-11-22 08:31

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 it always appears as an em

6条回答
  •  春和景丽
    2020-11-22 09:08

    Per HTML syntax, and even HTML5, the following are all valid options:

    
    
    
    
    
    
    
    

    Note that if you are using XML syntax the quotes (single or double) are required.

    Here's a jsfiddle showing all of the above working.

提交回复
热议问题