Javascript jQuery 添加 style="overflow: hidden;"
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14646669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery adding style="overflow: hidden;"
提问by LegendaryLaggy
I have created a bit of code to hide my menu, the menu is not complete but I am trying to use jQuery.slideUp()function but it adds style="overflow: hidden;"to the code so when I use .show one of my elements is hidden which is #nav:afterand #nav:beforewhich adds a small arrow to the bottom of the menu
我创建了一个位的代码隐藏我的菜单,菜单是不完整的,但我想使用jQuery.slideUp()的功能,但它增加了style="overflow: hidden;"对代码,所以当我用我的.show要素之一是隐藏这是#nav:after和#nav:before它增加了一个小箭头到菜单底部
here is the js code
这是js代码
$("span#start_button").click(function () {
if ($("#nav").is(":hidden")) {
$("#nav").show("fast");
} else {
$("#nav").slideUp();
}
});
and here is the result on this site
这是这个网站上的结果
How can I stop .slideUp()from creating style="overflow: hidden;"?
我怎样才能停止.slideUp()创作style="overflow: hidden;"?
回答by amd
You must remove the overflow:hiddenon the callback of the slideUp()function
so you can try
您必须删除该函数overflow:hidden的回调,slideUp()以便您可以尝试
$("#nav").slideUp('fast', function(){ $('#nav').css('overflow','visible') });
Or you can force it by css
或者你可以通过css强制它
#nav{overflow:visible!important}
回答by Andrey
This is bugin older jquery. This code replace standart function "slideDown" and delete overflow property.
这是较旧的 jquery 中的错误。此代码替换标准函数“slideDown”并删除溢出属性。
!(function (jQuery, origSlideDown) {
jQuery.fn.slideDown = function (speed, easing, callback) {
var self = this;
var args = Array.prototype.slice.call(arguments);
var origCallback;
for (var i = 0, len = args.length; i < len; i++) {
if (jQuery.isFunction(args[i])) {
origCallback = args[i];
args[i] = function () {
origCallback.call(this);
self.css('overflow', '');
}
}
}
if (!origCallback) {
args.push(function () {
self.css('overflow', '');
});
}
return origSlideDown.apply(this, args);
};
})(jQuery, jQuery.fn.slideDown);
回答by Jay Blanchard
Override that style -
覆盖那种风格 -
$("#nav").slideUp();
$("#nav").css({'overflow':'visible'});
回答by Srihari
Override the default styling by modifying the style attribute of html.
通过修改 html 的 style 属性覆盖默认样式。
else {
$("#nav").slideUp();
$("#nav").attr("style","overflow:visible");
}
回答by MG_Bautista
Try this...
尝试这个...
else {
$("#nav").slideUp();
$("#nav").css("overflow","visible");
}

