So you’re trying to populate the select from the labels? With what form controls would those labels actually be associated then? I mean there’s a lot hard-coded data in your JS that would probably better be inferred from the markup, such as the values of those control elements or data-* attributes. Same with the selector – don’t query for elements by their content; this is error prone as you’d have to adjust the JS whenever you change the wording (not to mention adding translations).
Anyway it looks like you’re prepending the option to the wrapper div, not the actual select… the best solution would be to simply give that select an ID:
Yes I’m trying to populate the select from the the label. The problem I have is that some of the fields are set up differently. For example, some selects are just under a label, whereas some are under a div which is under a label. It’s a huge script so now, that’s why i’m trying to modify it that way.
As I said, just give them IDs then and this doesn’t matter. If you want to populate multiple selects you might als store the target selector in a data-* attribute like so: