JSFiddle - React, Tailwind, and code Playground

HTML

<div name="name[1]"></div>
<div name="name[2]"></div>
<div name="name[3]"></div>
<div name="name[4]"></div>

CSS

div{
    width:40px;height:1px;
    padding:20px;
    background-color:#ccf;
    margin-top:10px;
    border:1px solid #000;
}

JavaScript

$('div[name="name[2]"]').html('Text2'); //correct
$('div[name="name\\[3\\]"]').html('Text3'); //correct but no need to escape
$('div[name=name\\[4\\]]').html('Text4'); //correct
$('div[name=name[1]]').html('Text'); //wrong - check the error in the console!