Jquery read element attribute id with square brackets [ ]

To use any of the meta-characters ( such as !”#$%&’()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id=”foo.bar”, can use the selector $(“#foo\\.bar”).

Example:

	$("#news_image\\["+no+"\\]")

Reference: Special Characters In Selectors

By Keenlio, July 16, 2014

One Comment

  1. Cecelia says:

    I just like the helpful info you supply in your articles.

    I will bookmark your weblog and check again right here frequently.

    I am fairly certain I’ll be told many new stuff right right here!
    Good luck for the next!

Leave a Comment to Cecelia

Leave a Reply to Cecelia Cancel reply

Your email address will not be published. Required fields are marked *


eight − 7 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>