I have following for loop. Which sees if the data value is in the dropdown if so it will show it as selected.
for (var i in data) {
$("#optionDropdwon option:contains(data[i])").prop("selected", true);
console.log(data[i])
}
It works fine when I replace data[i] in the :contains() with an actual string i.e "xyz"
but when I replace it with data[i] nothing happens. Yet I can see console.log(data[i]) shows me the proper values.
I searched Stackoverflow but couldn't find something like what I am doing.
Please let me know where I am making a mistake. Thanks