简体   繁体   English

如何在jquery调用函数中绑定选择菜单中定义的onchange事件?

[英]how to bind onchange event defined in a select menu in jquery call function?

i'm trying to implement clone select menu using the following plugin: 我正在尝试使用以下插件实现克隆选择菜单:

https://github.com/afEkenholm/ScrollectBox https://github.com/afEkenholm/ScrollectBox

https://github.com/afEkenholm/ScrollectBox/blob/master/index.html https://github.com/afEkenholm/ScrollectBox/blob/master/index.html

https://github.com/afEkenholm/ScrollectBox/blob/master/js/ScrollectBox/jquery.scrollectbox.js https://github.com/afEkenholm/ScrollectBox/blob/master/js/ScrollectBox/jquery.scrollectbox.js

but i'm unable to bind onchange event defined in the following select menu in jquery call function. 但是我无法在jquery调用函数中绑定以下选择菜单中定义的onchange事件。

    <select onchange="function(this);" id="selector" class="selection" >
    <option value="" selected="Select Topic">Select Topic</option> 
    <option value="Food">Food</option>
    <option value="Drink">Drink</option>
    </select>

how can i bind onchange="function(this);" 我怎么能绑定onchange="function(this);" in the following call function? 在以下的通话功能?

<script type="text/javascript">
jQuery(document).ready(function($){ 
   $(".selection").scrollectBox({
    preset: 'dropdown',
    numVisibleOptions: 4,
    scrollInterval: 150, 
    scrollOn: 'hover'
    });
});
</script>

thanks, 谢谢,

Use chaining in jQuery. 在jQuery中使用链接。

$(".selection").scrollectBox({
    preset: 'dropdown',
    numVisibleOptions: 4,
    scrollInterval: 150, 
    scrollOn: 'hover'
}).on('change', function() {
    // this
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM