I am trying to do this process:
- Find all classes that begin with “i18n_”
- Capture that class name, then set that class’ .html value to a variable with the same name as the class.
Basically I have a list that gets grabbed off the server with all the strings, beginning with i18n_. For example i18n_t23 = “Back” or something. I want to take the <span class="i18n_t23"></span> and set it’s value to the variable i18n_t23.
At the moment I have a massive list of hand-coded $(“span.i18n_t189”).html(i18n_t189); and it’s getting tiring to have to check if they’re all there. There must be a way to just have it do this automatically.
Thanks!
I would recomend you to slightly change your setup and thus simplify javascript code you’ve got:
So instead of class
i18_somethingyou are setting up custom data attribute data-i18 and put value here.