jQUery - insert   inside label

Viewed 31228

I want to hide a label using the fadeOut effect but when it is completed I want to insert inside it a  

 $('label.alert').fadeOut('slow',function(){$(this).text(' ');});

but it produces a   as a raw text. Any ideas ?

3 Answers

Be careful with using .html() or the same methods using another framework/library (e.g v-html in Vue.js), because it has XSS vulnerability. Read more about XSS from this answer.

Working way via .text():
You can simply replace   with \xa0 for text messages.

Related