Roy
Roy

Reputation: 51

how to assign height to div using variable?

how to assign height to div using variable? I know we can assign height with variable by putting variable inside of height method, but why its not taking height with assign operator.? here is the example below I was trying.

        $('.last-input input').focus(function(){
        console.log('focus');
        var keyboardHeight = $('.keyboard-div').height();
        var formrowH = $('.formrow').height();
        console.log('keyboardHeight', keyboardHeight);            
        console.log('formrow height', $('.formrow').height());
      //$('.formrow').height(formrowH)
        $('.formrow').height() = formrowH;
      });

Upvotes: 1

Views: 52

Answers (1)

elementzero23
elementzero23

Reputation: 1429

That is because

$('.formrow').height()

returns a value and not "the variable that determines the height"

As @Satpal pointed out, use

$('.formrow').height(formrowH)

to set the height of .formrow to the value stored in formrowH

Upvotes: 1

Related Questions