MalTec
MalTec

Reputation: 1370

jquery input slector

want to access select list where id starts with sentidd

$('.select[id^=sentidd]').change(function() {}

It fails. Whats the correct syntax?

Upvotes: 0

Views: 105

Answers (4)

ahsteele
ahsteele

Reputation: 26494

The following should do the trick:

$('select[id^="sentidd"]')

To play with jQuery selectors I recommend using the Interactive jQuery selector tester.

Upvotes: 4

justkt
justkt

Reputation: 14766

If your select has a class of select, what you provided will work.

If it doesn't, try:

$('select[id^="sentidd"]')

without a .. .<something> is the class selector. No dot means a tag selector. You can see what I provided in action here

Upvotes: 0

gen_Eric
gen_Eric

Reputation: 227260

You need to put the attribute value in quotes. You also have a . before select. This means elements with the class select not the HTML select tag.

The selector should be:

$('select[id^="sentidd"]')

Upvotes: 0

Daniel A. White
Daniel A. White

Reputation: 190943

Try this - select[id^="sentidd"] - notice the . is gone and the new "s.

Upvotes: 1

Related Questions