如何在zIndex中添加“重要" [英] How to add 'important' to zIndex

查看:74
本文介绍了如何在zIndex中添加“重要"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上的某些加载项之间存在冲突.使用Firebug,我注意到,如果在z-index中添加!important",就可以避免冲突.

I have conflict between some add-ons on my site. Using Firebug, I noticed that if I add "!important" to the z-index I can avoid the conflict.

但是z-index值是使用JavaScript而不是CSS设置的

but the z-index value is set using JavaScript and not CSS

那么我如何在以下JS代码中添加!important":

so how do I add "!important" to the following JS code:

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?]我了解我需要添加以下代码-

from the proposed answer [How to apply !important using .css()? ] I understand that I need to add the following code -

if (XXX.style.setProperty) {  // IE 9- does not support...
    XXX.style.setProperty ("z-index", (this???.element.zIndex() + 1), "important");
  }

如何添加它:我的情况下,XXX是什么?和这个"?

How do I add it: what is XXX in my case? and "this" ?

由于它已成为jQuery语法问题,所以我在-

Edit 2: Since it became jQuery syntax question, I asked it with different tags in - How to add 'if' to jQuery chain code

推荐答案

我在另一个线程中收到了答案-

I received the answer in another thread - How to add 'if' to jQuery chain code

使用-

.each(function() {
    this.style.cssText+= 'z-index: '+(parseInt($(this).css('z-index'))+1)+' !important';
  })

但是在几个函数中苦苦挣扎之后,我更愿意在该类中添加一个类和一个规则-

but after struggling with the code in several functions, I preferred to add a class and a rule to this class -

this.menu = $("<ul>")
  .addClass("ui-autocomplete")
  .addClass("ui-autocomplete-hover-header")  // !! added!
. . .

.ui-autocomplete.ui-autocomplete-hover-header {  
  z-index: 5004 !important; }

这篇关于如何在zIndex中添加“重要"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆