Aniket Aniket - 3 months ago 29
Javascript Question

Sumo select remove all indexes and reset

I have integrated Sumoselect. select it for cascading state and city dropdown.
Initially City drop is blank. On section of States, it adds Options under City dropdown.
Question is how to remove all options of City dropdown, if someone de-selects all the selected states?
There is only provision to remove options using index. So how to remove all the options at one time?

Answer

Get all indexes in num variable.

var num = $('option').length;

for(var i=num; i>=1; i--)
{
   $('.SlectBox')[0].sumo.remove(i-1);
}
Comments