Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increment or decrement height of a div using jquery

Tags:

jquery

This is my attempt to decrement by 28:

var addItemForm = $('.add-item-form');
var h = addItemForm.height()-28;
var h = toString(h);
addItemForm.height(h);

But it doesn't work.

like image 217
Hard worker Avatar asked Apr 18 '12 15:04

Hard worker


1 Answers

If your height is in pixels, you can just write:

​$(".add-item-form").height("-=28");​​​​​​​​​​​​​​​​​

... and similarly to increment:

$(".add-item-form").height("+=28");

Check out the documentation for height for more information.

Example: http://jsfiddle.net/VDcLs/

like image 104
Andrew Whitaker Avatar answered Oct 29 '22 21:10

Andrew Whitaker