将 CSS 属性添加到 jQuery
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5532076/
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
Add CSS property to jQuery
提问by JD Audi
I need to set a CSS property in this script to go along with the animation, but I can't seem to do it right.
我需要在此脚本中设置一个 CSS 属性以配合动画,但我似乎无法正确设置。
I need the div
with ID of "container" to have a CSS property set when the click function is activated. I need an overflow: hidden
set to #container
.
div
当点击功能被激活时,我需要ID 为“容器”的 CSS 属性设置。我需要overflow: hidden
一套#container
。
Here's my script.
这是我的脚本。
$(function() {
$(".folderContent").hide();
$(".signin").click(function(event) {
var folderContent = $(".folderContent");
var folderContentShown = folderContent.css("display") != "none";
var clickedFolder = $(this);
clickedFolder.parent("#signincontainer").after(folderContent);
$("body").find("#container").not(clickedFolder).each(function() {
if (!folderContentShown) $(this).not("#signincontainer").animate( {
opacity: 0.50
}, "slow");
else $(this).animate({
opacity: 1.00
}, "slow");
});
//clickedFolder.animate({opacity: folderContentShown ? 1.00 : 0.70}, "fast");
folderContent.slideToggle();
event.preventDefault();
});
});
回答by Damb
$('#container').css('overflow','hidden');
Did you try this?
你试过这个吗?
回答by trgraglia
You should just go to the jquery site and read it... it will make more sense and it is really straight forward.
你应该去 jquery 网站阅读它......它会更有意义,而且它真的很简单。
回答by kishan Radadiya
回答by Dostonbek Oripjonov
You can also add multiple attributes
您还可以添加多个属性
$('select_smth').css({
'color' : 'red',
'height' : '10px'
});