Windows – Linux – Mac OSX Guides

Jquery selector problem with IDs have square brackets

I’m using PHP quite often in my work, and have the habits to put the form name in the syntax of array, such as

But the problem happened when I use Jquery selector to select the element

This will not work

$(“#product[title]”)

But this will work

$(“:input[id=’product[title]’]”)

There is another way is escape the square by putting \\ before the
square brackets

$(“#product\\[title\\]”)

Hope that help someone having the same trouble like me.

Related Articles

Loading Facebook Comments ...

2 Comments

  1. alex

    Thanks this help me

  2. Evgeny

    $(“#product\\[title\\]“)
    not working in Opera moobile.

Post your comments

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