Escaping text with jQuery append?

前端 未结 3 1256
我在风中等你
我在风中等你 2020-12-18 19:31

I know that I can use $.html to set the HTML content of something, and $.text to set the content (and that this escapes the HTML).

Unfortun

3条回答
  •  感动是毒
    2020-12-18 19:55

    You're appending an element which already has content? Or you're adding the content after you append? Either way, you still need to do .text(...) on that element.

    If you're using append and passing HTML as the argument, then try creating the element first, and passing it to append.

    Ex:

    $('
    ').text('your content here').appendTo('div#someid')

提交回复
热议问题