Hello to all

There is such jQuery code:

var parent = $(this).parents('.work-examples__li'); var tarGet = parent.find(".example"); var activeBlock = parent.find(".work-examples__li_active"); var tarGetHeight = tarGet.height(); if (!tarGet.hasClass('pop-up')) { tarGet.addClass('pop-up'); activeBlock.addClass('visible'); parent.css("padding-bottom", 'tarGetHeight') 

When executed, parent gets style = "" (the variable is not readable for some reason), and if I remove the brackets

 parent.css("padding-bottom", tarGetHeight) 

then padding gets 0px;

What could be the problem?

    1 answer 1

    This is how it should work:

     $(parent).css({"padding-bottom" : tarGetHeight}); 

    Try it. :)

    UPD : I did not immediately notice. And how do you use jQuery functions? :) Corrected your answer.

    • I'll try. Is this a crutch an hour? I see such a record for the first time - Nikita Shchypylov
    • @ Nikita Schipilov No, this is not a crutch. I advise you to read of. Documentation: api.jquery.com/css - intro94
    • It did not work. Gives 0 pixels - Nikita Shchypylov
    • And what gives alert(tarGetHeight); ? Can you accept 0 in tarGetHeight itself? - intro94
    • No, I was outputting -417 px through the console - Nikita Shchypylov