Ok, this is a weird request, but I need to use jQuery to manipulate a bunch of tags that all have the same id and name.
We’re using Izenda AdHoc reporting controls, which has a query designer GUI. It gives you a select dropdown with a list of tables in it, and you can click a button and get another one, and another and another etc. to build your query.
Every time you click for a new table it posts back to the server, and comes back with a new row in the table, with the same controls as the row above, including an identical select tag, with the same id and name attributes. How ASP.NET is generating this is beyond me.
But I was using jQuery to modify the length of the dropdowns as they are too short. Strangely enough, even though they all have the same id, using jQuery like:
jQuery("#ctl00_ContentPlaceHolder1_queryBuilder_ctl101_jtc_Table").width(250);
will only change the first dropdown. I need to widen them all, but they all have the same ID. And there are lots of other select tags I dont want to touch.
Any ideas?
EDIT:
Now that I think about it, I have no idea how this even works. The page poasts back, saves the datasources etc. everything seems to work, but I have no idea how ASP.NET tells one dropdown from another. But it does work.
$("#yourid")will only match the first one (since, of course, all your IDs should be the unique).If you can’t have unique IDs then it’s possible to access them using the attribute equals selector
$("input[id='yourid']");. This will return all of the matching elements.See it working : http://jsfiddle.net/jonathon/22mpK/