Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add CSS property to jQuery

Tags:

jquery

css

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.

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.

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();
    });
});
like image 624
JD Audi Avatar asked Apr 03 '11 19:04

JD Audi


People also ask

Can we change CSS property using JavaScript and jQuery?

It is possible to change the CSS property of an element by using a simple JavaScript API, but we try to complete this challenge using jQuery css() method. Syntax: $().

What is the use of CSS () method in jQuery?

jQuery css() Method The css() method sets or returns one or more style properties for the selected elements. When used to return properties: This method returns the specified CSS property value of the FIRST matched element.

How can check CSS property value in jQuery?

You can get the computed value of an element's CSS property by simply passing the property name as a parameter to the css() method. Here's the basic syntax: $(selector). css("propertyName");

How can use multiple CSS properties in jQuery?

Apply multiple CSS properties using a single JQuery method CSS( {key1:val1, key2:val2....). You can apply as many properties as you like in a single call. Here you can pass key as property and val as its value as described above.


2 Answers

$('#container').css('overflow','hidden');

Did you try this?

like image 130
Damb Avatar answered Oct 18 '22 15:10

Damb


You should just go to the jquery site and read it... it will make more sense and it is really straight forward.

http://api.jquery.com/css/

like image 34
Anthony Graglia Avatar answered Oct 18 '22 13:10

Anthony Graglia