JSFiddle - React, Tailwind, and code Playground

HTML

<div id="foobar">loading</div>
<div id="barfoo">loading</div>

JavaScript

$(function() {
   
   $('#foobar').attr('foo','blah'); 
    
    $('div').each(function() {
       
        if($(this).attr('foo')) {
         
           $(this).text('I have the attribute of foo');
            
        } else {
         
          $(this).text('I don\'t have the attribute of foo');
            
        }
        
    });
    
});