JSFiddle - React, Tailwind, and code Playground

HTML

<div id='foo[1]'>a</div>
<div id='foo[2]'>b</div>

JavaScript

$(document).ready(function() {
   $('#foo[1]').text('stuff here'); 
   $('div[id="foo[2]"]').text('stuff here'); 
});