Javascript Firefox与具体的自定义选择框有关
有一个自定义的选择框,Firefox无法与之交互。有人知道问题出在哪里吗?我想问题出在下面的代码中:Javascript Firefox与具体的自定义选择框有关,javascript,jquery,html,css,Javascript,Jquery,Html,Css,有一个自定义的选择框,Firefox无法与之交互。有人知道问题出在哪里吗?我想问题出在下面的代码中: $(".custom-select-trigger").on("click", function() { $('html').one('click',function() { $(".custom-select").removeClass("opened"); }); $(this).parents(".custom-select").toggleClas
$(".custom-select-trigger").on("click", function() {
$('html').one('click',function() {
$(".custom-select").removeClass("opened");
});
$(this).parents(".custom-select").toggleClass("opened");
event.stopPropagation();
});
选择框在这里:如果您检查控制台,它会显示
未定义事件
此处为
$(“.custom select trigger”)。在(“单击”,function(){
上,您需要添加事件,因此它显示为$(“.custom select trigger”)。在(“单击”,function(event){
引用错误:未定义事件
错误显示在firefox控制台中。这意味着您正在使用未定义的事件
。因此,请按如下方式重写代码
$(".custom-select-trigger").on("click", function(event) {//added event here
$('html').one('click',function() {
$(".custom-select").removeClass("opened");
});
$(this).parents(".custom-select").toggleClass("opened");
event.stopPropagation();
});
可能存在的副本
$(".custom-select-trigger").click(function() {
$(this).parent().toggleClass("opened");
});