I have following setup:
<div class="vc_acf organisation">
<span class="vc_acf-label">Organisation:</span> CLEMI</div>
</div>
I want to change it in:
<div class="vc_acf organisation">
<span class="vc_acf-label">Organisation:</span> <a href="https://beglobal.toc-web.site/resources/clemi">CLEMI</a></div>
</div>
What I got so far:
(function($) {
$(".organisation").each(function() {
$(this).html($(this).html().replace(/CLEMI/g, "<a href='https://beglobal.toc-web.site/resources/clemi'>CLEMI</a>"));
});
})(jQuery);
This works perfectly but I have dozens of organizations (like CLEMI is one of them). The field .organisation is dynamically created and always changes. So I don’t want to write the jQuery for every organization but find a shortcut to select the content of that element and wrap it a link and also change the url of that link.
*Note sometimes the organization exists of two word, for example: SOS Faim the link should be then: https://beglobal.toc-web.site/resources/sos-faim
2
Answers
This could be solution to your problem
you can try something like this:
fiddle : https://jsfiddle.net/v3z6eg82/