Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQuery to Iterate Over Select List

 
Steve Dyke
Ranch Hand
Posts: 1679
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For what ever reason the following will only return a value if an element is selected and then only that element.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's an id selector, so there can be only one element with that id. So why bother iterating over it?

If you have more than one element with the same id, that's not valid HTML and whatever happens is non-deterministic.
 
Steve Dyke
Ranch Hand
Posts: 1679
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:That's an id selector, so there can be only one element with that id. So why bother iterating over it?

If you have more than one element with the same id, that's not valid HTML and whatever happens is non-deterministic.


I did not have the selector set up right. I had to add 'options' to it and it worked.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have more than one element with the same id, it's guaranteed to stop working at the most inopportune time. Be sure that there is only one element with a unique id value.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic