I want to be able to extract a certain part of the classes only if it contains a certain value.
Let’s say I have <div class=”aa bb blog-xxx”></div>
I want to be able to only extract blog-xxx
{{Click Classes}} is a variable from Google Tag Manager
I have tried the following code:
function blogChecker(string) {
var el = {{Click Classes}};
if (el.includes("blog")) {
return el;
}
}
which extracts “aa bb blog-xxx” but I only want “blog-xxx”