tags:

views:

29

answers:

3

Hi I want to apply min-height to ".wide-content"

min-height of .wide-content = height of right content - "274px"

var leftHeight = $(".wide.content").height();
var rightHeight = $("#right_column").height();
alert (leftHeight); alert (rightHeight);

if (leftHeight < rightHeight) {
  $(".wide.content").css('minHeight' 'leftHeight - 274');
}

Thanks in Advance

+1  A: 

Instead of a string for the assigned value, you need the actual number, like this:

if (leftHeight < rightHeight) {
  $(".wide.content").css('minHeight', leftHeight - 274);
}

Also when using .css(), instead of .css('prop' 'value') you need a comma in there, like this:

$(selector).css('prop', 'value');
//or:
$(selector).css({'prop': 'value'}); //when assigning many at once, like this:
$(selector).css({'prop': 'value', 'prop2': 'value2'});
Nick Craver
A: 

JQuery follows camelCase naming convention as well - separated css property naming convention.

Exampl:

CSS             JQuery
=========       =======
font-size       fontSize or font-size
border-width    borderWidth or border-width
Sadat
This isn't accurate, jQuery lets you specify *either*, it'll convert a capital letter into `-lowercase`, e.g. `C` becomes `-c` in the string, it's a very simple regex conversion. That being said, he's following that convention, `minHeight` == `min-height` already.
Nick Craver
Thanks @Nick, you are right.
Sadat
+1  A: 

The following piece of code works for me.

   $('#test').css({
      minHeight: 500
    });
alokswain