What is the difference between these different ways to escape square brackets inside jQuery selectors.
Is there a right or wrong way or are these both correct? I have read different answers (including this) but none compare this different ways.
HTML
<div name="name[1]"></div>
jQuery
$('div[name=name[1]]'); //wrong
$('div[name="name[1]"]'); //correct?
$('div[name="name\\[1\\]"]'); //correct?
$('div[name=name\\[1\\]]'); //correct?
All those I ask correct? work, is that ok way/syntax to use the selector?
EDIT :
I read the duplicate suggested answer before I posted actually and it does not explain the differences or which should be used... I got that now from this answer.