0

I have this piece of JS:

for(var index in response.rates) {
    select.options[select.options.length] = new Option([index], index);
}

It generates the and tags populated with an array.

How can I give attributes to from there? Like onselect and and other things.

2

1 Answer 1

2

Assign the option to a variable then you can give it attributes.

for(var index in response.rates) {
    let option = new Option(index, index);
    option.addEventListener("select", ...);
    select.options[select.options.length] = option;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.