见小提琴:http://jsfiddle.net/csaltyj/P2sLa/
在Chrome中,这种方法很好,但在Firefox中却没有,并产生Javascript警告.我知道这里不需要!important,但我有一个需要的大型项目,这导致Firefox崩溃.有任何想法吗?
可能重复:
Jquery css:应用!重要样式
我有以下代码:
$("body")
.ajaxStart(function () {
$(this).css({ 'cursor': 'progress' })
})
.ajaxStop(function () {
$(this).css({ 'cursor': 'default' })
});
Run Code Online (Sandbox Code Playgroud)
这可行但不是当我将鼠标悬停在我有悬停和不同光标的链接上时.有没有办法可以使用jQuery>将上面的CSS游标属性设置为重要
有没有办法可以使用JQuery的.css()方法来提供以下光标样式?:
cursor: url(http://www.google.com/intl/en_ALL/mapfiles/closedhand.cur), default !important;
Run Code Online (Sandbox Code Playgroud) $(".mydiv").css('width', $(".image").width());
Run Code Online (Sandbox Code Playgroud)
这段代码工作正常,但我想让这个宽度变得重要,正确的方法是什么?
我试过这个,但它不起作用
$(".mydiv").css('width', $(".image").width()+'!important');
Run Code Online (Sandbox Code Playgroud)
(!重要)
我有这个代码
$('#downvotebutton').click(function() {
$(this).css('background-color', 'red !important');
console.log('foo');
//more
Run Code Online (Sandbox Code Playgroud)
单击downvotebutton时,'foo'将返回到控制台,但背景颜色不会更改.jQuery链接到页面的其他地方并在其他地方工作.可能是什么原因?
我已经为其他人创建了一个jQuery小部件嵌入他们的网站,在小部件中我使用了一个名为"cleanslate"的css reset样式表:
https://github.com/premasagar/cleanslate
这会阻止页面样式进入我的窗口小部件.
问题是我的fadeOut和fadeIn不再有效,因为重置样式覆盖了displayjQuery添加的内联样式.我需要使fadeOut函数添加!important;到内联样式.
有谁知道这是否可能?
提前致谢.
我正在尝试使用jquery的animate()函数更改图像元素的高度和宽度.CSS中的图像高度和宽度属性后跟"!important".
CSS:
#my_image {
height: 50px !important;
width: 50px !important;
}
Run Code Online (Sandbox Code Playgroud)
由于"!important"规则,以下jquery代码无效:
$('#my_image').animate({ height: "100px;", width: "100px"}, 1000 );
Run Code Online (Sandbox Code Playgroud)
有没有办法使用jquery动画图像(如果不存在"!important"规则会发生这种情况)?谢谢.
我有一个自举面板,我设法设置身体的不透明度.
<div class="panel panel-default" style="background:none;">
<div class="panel-heading">What is needed to perform activity?</div>
<div class="panel-body" id="needsBody">
Panel content
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用css如下
#needsBody {
background: rgba(255, 255, 255, 0.3) !important;
}
Run Code Online (Sandbox Code Playgroud)
我想使用jquery(或javascript)动态设置颜色,如下所示尽管它不起作用.
$("#needsBody").css("background", "rgba(175, 201, 99, 0.2) !important;");
Run Code Online (Sandbox Code Playgroud)
我将如何有效地做到这一点?
我对这个 JQuery 脚本有一些问题(在使用Jquery-1.9.1.min.js 的项目上):
$(document).ready(function () {
$("thead.opening").click(function () {
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
alert("INTO second function, chrome: " + is_chrome);
$(this).next().css('width', '10000000em');
$(this).next().css('display', 'table-row-group');
//$(this).next().css('display', is_chrome ? 'table-row-group' : 'table-row-group');
//alert($(this).next().css('display'));
});
});
Run Code Online (Sandbox Code Playgroud)
该脚本只是将 CSS 样式设置为与单击的thead元素相关的tbody元素,并按以下方式执行:
$(this).next().css('display', 'table-row-group');
Run Code Online (Sandbox Code Playgroud)
它可以工作,但我还必须为此 CSS 属性设置!important,但如果我这样做,它就无法工作:
$(this).next().css('display', 'table-row-group !important');
Run Code Online (Sandbox Code Playgroud)
所以在网上搜索我在 StackOverflow 上找到了这篇文章:How to apply !important using .css()?
因此,在前面的脚本中,我尝试使用:
$(this).next().style('width', '10000000em', 'important');
$(this).next().style('display', 'table-row-group', 'important');
Run Code Online (Sandbox Code Playgroud)
反而:
$(this).next().css('width', '10000000em');
$(this).next().css('display', 'table-row-group');
Run Code Online (Sandbox Code Playgroud)
但问题是我得到了这个错误的结果:
<tbody class="expanded" style="display: block; …Run Code Online (Sandbox Code Playgroud)