【问题标题】:Different icons for multiple Select2 dropdowns多个 Select2 下拉菜单的不同图标
【发布时间】:2018-04-27 17:16:56
【问题描述】:

我目前正在使用 Select2 使我的下拉列表可搜索。我已经到了可以更改图标的地步,但是现在当我在另一个下拉列表中调用 Select2 并更改图标时,它会显示两次。这是我目前拥有的代码;

    $(".where__heading").select2({
        placeholder: "Try 'Belfast'",
        allowClear: false,
    });
    $('b[role="presentation"]').hide();
    $('.select2-selection__arrow').append('<img src="images/icons/travel.svg" alt="">');

   Calling in it again below on a different dropdown....

    $(".how__long").select2({
        placeholder: "1-2 days",
        allowClear: false,
    });
    $('b[role="presentation"]').hide();
    $('.select2-selection__arrow').append('<img src="images/icons/time.svg" alt="">');

我似乎无法弄清楚这一点。我只需要更精确吗?

$('.select2-selection__arrow').append('<img src="images/icons/time.svg" alt="">');

感谢您的帮助:)

【问题讨论】:

  • 你能在演示中添加这个吗? ,另一种情况,我认为他刷新了她的列表,因此可能具有您可以控制此事件的功能..

标签: jquery html select jquery-select2 dropdown


【解决方案1】:

是的,它需要更精确。这样的事情会奏效。

$('.where__heading').next().find('span.select2-selection__arrow').append('<img src="images/icons/travel.svg" alt="">');
$('.how__long').next().find('span.select2-selection__arrow').append('<img src="images/icons/time.svg" alt="">');

【讨论】:

    猜你喜欢
    • 2021-10-06
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    • 2018-08-18
    • 1970-01-01
    • 2016-03-20
    • 2021-07-08
    • 1970-01-01
    相关资源
    最近更新 更多