JSFiddle - React, Tailwind, and code Playground

by lukempeters

HTML

<div class="userProfile">
    <h2 class="pageTitle">Your Name<br><small class="smallUsername">jgibson</small></h2>
</div>

CSS

body {
    margin: 40px;
    font-family: Arial;
    font-size: 16px;
}

.tooltip {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 3px 7px 4px 7px;
    font-size: 12px;
    color: #ffffff;
    border-radius: 2px;
    background: rgba(0,0,0,0.6);
    background: #2b2b2b\9;
}

.arrow {
    position: absolute;
    top: 6px;
    right: -10px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent;
    border-left-color: rgba(0,0,0,0.6);
}

.pageTitle {
    position: relative;
    padding: 18px 20px;
    color: #3b3b3bl;
    background: #ccffff;
}

.defaultName {
    color: red;
}

JavaScript

if($('.userProfile').length > 0){
    
    $('.userProfile .pageTitle').each(function() {
        
        if($(this).html().indexOf('Your Name') > -1){
            $(this).parent('.userProfile').append('<div class="tooltip"><div class="arrow"></div>Change your name</div>');
        }

    });

}