In my case I use jQuery and PHP. I can add data width jQuery and when I do it creates new div tags.
The problem I have is if I add “My åäö test” to a div class for example it looks like this:
<div class="My åäö test">
In fact, that’s three classes. I somehow need to sanitize it like the way WordPress does:
My result should be:
<div class="my-aao-test">
Any other suggestions how to better store data attached to divs or other elements are also welcome.
Why not use the same function that WordPress uses?
You could pass it via ajax to be sanitized and then returned.
Taken from the source: