how can I do a jQuery swear word / bad word filter?

前端 未结 6 434
情话喂你
情话喂你 2020-12-05 05:53

I know there are many arguments as to why this is a bad idea, but in my implementation I\'m planning on enabling/disabling bad words in the account settings. In other words

6条回答
  •  一生所求
    2020-12-05 06:43

    The JSON object you return cannot have repeated attribute names. Instead of { w: 'Swear1', w: 'Swear2' } it should be [ 'Swear1', 'Swear2' ].

    You can parse the text to filter and wrap every occurrence of a swear word between tags with a particular class attribute and toggle them with a function. That should be a simple approach.

提交回复
热议问题