var obj:
{1: Array(1), 2: Array(1), 5: Array(3), 6: Array(3), 27: Array(2)}
1: ["BC8907"]
2: ["B6789"]
5: (3) ["H67890", "BC567", "BC8907"]
6: (3) ["BH123", "BH1234", "BM2345"]
27: (2) ["EPC123", "EPC1234"]
As you can see from the above array, there are five keys(1,2,5,6,27).
I have a set of select tags in the DOM, with any one of the array key as class name. I'm trying to append values to all the dropdowns as options for the matching key as class names.
For example:
<select name="hno[]" class="5">
<option value="BC8907" selected="">BC8907</option>
</select>
In the above dropdown, need to append the values of the key 5(H67890,BC567) as the dropdown also having the same number as class name. Also, need to ignore the value BC8907 as the dropdown already has the same value.
Expected Output:
<select name="hno[]" class="5">
<option value="BC8907" selected="">BC8907</option>
<option>H67890</option>
<option>BC567</option>
</select>
I tried with jquery each but it's not working as expected.
Note: The array values and the dropdown class names are dynamically added.