Attach click-event to element in .select2-result

后端 未结 12 1822
猫巷女王i
猫巷女王i 2020-11-29 02:06

I\'m looking for a way to attach a click-event to a select2-result-item. I\'ve gone ahead and formatted both result and selection via

function format(state)          


        
12条回答
  •  春和景丽
    2020-11-29 02:26

    Just add 'open' listener and set up another 'mouseup' listener for the '' tag:

    $("#select").on('open', function() { 
        $('.select2-results i').on('mouseup', function() { 
           alert('aaa');
        }); 
    });
    

    Here is the link to my solution: http://jsfiddle.net/EW8t7/

提交回复
热议问题