Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQuery to Iterate Over Select List

 
Steve Dyke
Ranch Hand
Posts: 1616
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: 64629
86
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: 1616
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: 64629
86
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic