我网站上的某些附加组件之间存在冲突。使用 Firebug,我注意到如果我将“!important”添加到 z 索引,我可以避免冲突。
但 z-index 值是使用 JavaScript 设置的,而不是 CSS
那么如何在以下 JS 代码中添加“!important”:
this.menu = $("<ul>")
.addClass("ui-autocomplete")
.appendTo(this.document.find(this.options.appendTo || "body")[0])
.zIndex(this.element.zIndex() + 1) // !! <- here // !!
.hide()
.data("menu");
编辑:来自建议的答案[如何使用 .css() 来应用 !important ? https://stackoverflow.com/questions/2655925/how-to-apply-important-using-css] 我知道我需要添加以下代码 -
if (XXX.style.setProperty) { // IE 9- does not support...
XXX.style.setProperty ("z-index", (this???.element.zIndex() + 1), "important");
}
如何添加:我的情况下 XXX 是什么?和这个” ?
编辑2:由于它变成了 jQuery 语法问题,我用不同的标签来问它 -如何将“if”添加到 jQuery 链码 https://stackoverflow.com/questions/30556847/how-to-add-if-to-jquery-chain-code
我在另一个帖子中收到了答案 -如何将“if”添加到 jQuery 链码 https://stackoverflow.com/questions/30556847/how-to-add-if-to-jquery-chain-code/30557946#comment49188395_30557946
use -
.each(function() {
this.style.cssText+= 'z-index: '+(parseInt($(this).css('z-index'))+1)+' !important';
})
但在与几个函数中的代码进行斗争之后,我更愿意向此类添加一个类和一个规则 -
this.menu = $("<ul>")
.addClass("ui-autocomplete")
.addClass("ui-autocomplete-hover-header") // !! added!
. . .
.ui-autocomplete.ui-autocomplete-hover-header {
z-index: 5004 !important; }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)