I have an input field that looks like this:
I was trying to change
You need to use attribute equals selector [name="value"]
Also from the docs:
To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\
So you can do:
jQuery('input[name="submitted\\[event_email\\]"]').val('test');
But actually you don't need to escape the [ ]
here since it's wrapping in quotes:
jQuery('[name="submitted[event_email]"]').val('test');
You need to to escape [
and ]
using \
but \
is also special character so we escape it also.
so we escape using \\
jQuery('[name="submitted\\[event_email\\]"]').val('test');
Attribute Equals Selector [name="value"]
Fiddle Demo
There is no need to escape [
and ]
as it is wrapped in quotes (i.e It is string)
jQuery('[name="submitted[event_email]"]').val('test');
// ^ ^