[英]Dropdown Code works in Chrome but not in Safari?
Anyone know why this dropdown code would be working in Chrome(mac), but not Safari(mac)? 有人知道为什么此下拉代码可以在Chrome(mac)中运行,但不能在Safari(mac)中运行吗?
http://jsfiddle.net/v917ycp6/5/ http://jsfiddle.net/v917ycp6/5/
$(function(){
var $cat = $("#category1"),
$subcat = $("#category2");
$cat.on("change",function(){
var _rel = $(this).val();
$subcat.find("option").attr("style","");
$subcat.val("");
if(!_rel) return $subcat.prop("disabled",true);
$subcat.find("[rel="+_rel+"]").show();
$subcat.prop("disabled",false);
});
}); });
It seems that Safari's selects doesn't work the same as Chrome, and it doesn't allow to disable options with display: none nor with the hidden attribute, so you will need to remove the option elements from the parent select. 似乎Safari的selects与Chrome的功能不同,它不允许使用display禁用选项:none或hidden属性,因此您需要从父select中删除option元素。 Other option might be to have 3 different selects, one for each category, and what you show / hide are the full selects in this case.
其他选项可能是具有3个不同的选择,每个类别一个,在这种情况下,显示/隐藏的是全部选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.