[RESOLVED]If I have two controls on a page; Control1 and Control12, If I use $('div[id*=Control1') to try to access Control1, it will find "Control12" if it is before "Control1" in the html.

If I have two controls on a page; Control1 and Control12, If I use $(‘div[id*=Control1′) to try to access Control1, it will find "Control12" if it is before "Control1" in the html.

What is the syntax to find just "Control1"? I tried getting rid of the *, but it then gives me an error.

I want to feed variables to find controls, and so I can’t use document.getElementByID  so it isn’t an option.

Thanks!

The * denotes "contains" which is why it matches the other id.

I assume your control id’s are getting prefixed by asp.net which is why your doing a wildcard type search?

how about going an "ends with" search instead by replacing the * with a $  ?

$('div[id$=Control1')

Thanks!!

Leave a Reply