Jquery events for closing and opening select drop down , and not on change

后端 未结 1 1366
無奈伤痛
無奈伤痛 2020-12-12 01:55

i want a neat solution to handle event for a drop down menu , so that when user opens the select menu , it alerts opened , and when he closes it , it alerts closed , neglect

1条回答
  •  猫巷女王i
    2020-12-12 02:39

    the typical approach to extending the native functionality of a select box is to replace it with styleable markup and then tie the values of the new markup back into the origninal (now hidden) select element. (NOTE: I've not included any styles. This is a bare-bones example of using a select replacement).

    var SelectBox = {
    init: function () {
        if ($('select').length > 0) {
            this.generateStyledSelectbox('custom-select');
        };
    },
    
    generateStyledSelectbox: function (cssClass) {
    
        // Contained within .each to isolate all instances of 
                            
        
    提交评论

提交回复
热议问题