Raje
Raje

Reputation: 3333

How to specify height in jquery css method

I would like to set height for div element in the form of percentage. not by pixel wise.

$("#div1").height("200px"); 

so how should I set this in percentage wise?

Upvotes: 2

Views: 68

Answers (2)

MD Sayem Ahmed
MD Sayem Ahmed

Reputation: 29166

$("#div1").css("height", "20%");

sets the height to 20% of the element with id div1

Upvotes: 4

Sufendy
Sufendy

Reputation: 1242

you might need to set your body and html tag to 100%.

//css
html, body {
    height: 100%;
}

then just change the px to %

$("#div1").height("20%");

Upvotes: 3

Related Questions