3

I am trying to check in the AJAX call if length of the response variable is bigger then 1. If that is true I need to add this style to my footer:

success: function(response) {
    for (var i = 0, len = response.results.length; i < len; i++) 
        {
            if(response.results.length>1)
            {
               $("#footer").css("position:relative");
            }
        }....
}

This is my predefined style in my css file:

#footer
    {
        z-index:11;
        bottom:0;
        position: fixed;
        float: left;
        width:100%;
        height:30px;
        background-color:black;
    }

I did some debugging and everything is working as it should be working but my footer element still has position:fixed

What am I doing wrong in here?

3 Answers 3

7

Try:

$("#footer").css("position", "relative");

or:

$("#footer").css({ position: "relative" });

:)

Sign up to request clarification or add additional context in comments.

Comments

2

Syntax of .css() is wrong. It is:

$('#element').css('property', 'value');

Take a look at the documentation.

Comments

1
 document.getElementById('footer').style.position ='relative';

Comments

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.