Select2: Hide certain options dynamically

前端 未结 10 779
情深已故
情深已故 2020-12-03 06:56

Basically what I\'m looking for is the ability to hide options from the dropdown of select items. So, technically they would still be options, but you just wouldn\'t be able

10条回答
  •  庸人自扰
    2020-12-03 07:30

    If somebody wants a another option using jquery data tags this woks for me:

    $('.select2 option').each(function(){
            if ($(this).data('condition') != 'true' ) {
              $(this).wrap('
    ') } else { $(this).unwrap('div') } })

提交回复
热议问题