[英]How to trigger the native select box using SelectBoxIt jquery plugin
[英]How To Detect Option Change When Using selectBoxIt JQuery Plugin?
$(".abc123").selectBoxIt();
$(document).on('mousedown', function(e) {
if ($(e.target).parent().parent().parent().parent().children(":first").hasClass('abc123')) {
var anchor = $(this).find('a');
var test = $(anchor).text();
alert($(this).parent().attr('class'));
}
})
以上是我更大的脚本的片段,我正在尝试应用其他功能mousedown部分。 我正在使用selectBoxIt JQuery插件,它会将任何基本选择选项列表转换为更漂亮的版本。
即使你使用插件来设置select
样式,你仍然可以挂钩底层元素的change
事件,如下所示:
$(".abc123").selectBoxIt().change(function() {
console.log(this.value);
});
我不确定你当前的代码究竟在尝试做什么,因为this
是document
,因此尝试获取parent()
是没有意义的,但是上面的代码至少会在选择更改时获得select的当前值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.