7

Hi I have one questions For example :

$("#menu").click(function(){
    $("#left_panel, #main_footer").fadeToggle(200);
    $("#input_content").css({width:"100%"});
});

And I want after this function css get default property

2

2 Answers 2

3

Default height value is auto, so you can set it back with:

$("#input_content").css({ width: 'auto' });
Sign up to request clarification or add additional context in comments.

Comments

0

The simpliest way is to set the style to something useless. Then the browser won't interpret it and fall back to the rules you've defined in your CSS. The standard way would be setting it to an empty value:

$("#input_content").css("width","");

If you want to fully reset it to its default value defined by the browsers stylesheet, you may try to set the value to "initial":

$("#input_content").css("width","initial");

Or you set the default value yourself, which is "auto" (See W3C).

3 Comments

I want when i again clicked $("#menu") selector get back default css value
Since .css() sets the styles inline, you may simply check if the element has the width attribute set or not. if($("#input_content")[0].style.width == "") { Set to 100% } else { reset to default (see my answer) }
Please Write this example jsfiddle

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.