How do I properly escape quotes inside HTML attributes?

前端 未结 6 949
遇见更好的自我
遇见更好的自我 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:23

    If you are using Javascript and Lodash, then you can use _.escape(), which escapes ", ', <, >, and &.

    See here: https://lodash.com/docs/#escape

提交回复
热议问题