最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Sumo select remove all indexes and reset - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question edited Jul 31, 2018 at 7:22 Nimeshka Srimal 8,9705 gold badges45 silver badges60 bronze badges asked May 19, 2016 at 13:38 AniketAniket 1291 silver badge10 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

You can delete all the HTML of the select element linked to SumoSelect and then reload the SumoSelect of that element. For example:

$('#MySelect').html('');
$('#MySelect')[0].sumo.reload();

Get all indexes in num variable.

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

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

评论列表(0)

  1. 暂无评论