JSFiddle - React, Tailwind, and code Playground
HTML
<span id="foo[1]">hello</span>
<span id="foo[2]">there</span>
JavaScript
$(function() {
$('<input type="button" value="click me">').appendTo('body').click(function() {
$('[id=foo\[1\]]').html('foo');
$('[id=foo\[2\]]').html('bar');
});
});