JSFiddle - React, Tailwind, and code Playground

by David Thomas

HTML

<body class="foo">
    <a href="#" class="foo bar">link text</a>
    <a href="#" class="bar">link text</a>
</body>

CSS

.bodySharesClass {
    color: #000;
    background-color: #f90;
    text-decoration: none;
}

JavaScript

$('a').each(
    function(i) {
        var classes = this.className.split(/\s+/);
        for (var i=0,len=classes.length; i<len; i++){
            if ($('body').hasClass(classes[i])){
                $(this).addClass('bodySharesClass');
            }
        }
    });