I\'m using jQuery to manipulate form data in an osCommerce instance and I\'m having trouble selecting some elements.
The script generates textareas with the id product_d
$("#product_description\\[1\\]").attr("id", "products_description_1");
is the right code, look at "ID-Selector" on jQuery.com
Try this:
$('#product_description\\[1\\]')
Note that while this may work, the bracket characters are not valid for use in IDs prior to HTML5 (although they're fine for use in classes).
The []
characters are not valid ID characters in HTML4. Don't expect consistent results in different browsers if you use them.
EDIT:
If you just can't control the format of the IDs on the server side, you could do this:
$("*[id='product_description[1]']")
but it will be terribly slow in browsers that don't support querySelectorAll
.
(Note that you shouldn't need the \\
here because of the quotation marks around the value.)