skip to Main Content

How can I remove the height CSS property from my div with id balls-conatiner? Below is the method used but it is not working.

$('#btn').on('click', function() {
  var $container = $('#balls-container');
  const div = document.createElement('div');
  div.classList.add('ball');
  $container.append(div);
  $container.css({
    height: "",
  });
})

$conatiner.removeProp('height')  

and also

$container.css({ height: "", }); 

but nothing is working.

3

Answers


  1. Try replacing

    $container.css({
      height:"",
    });
    

    with

    $container.css("height", "auto");
    

    in the place of auto you can add any values

    Login or Signup to reply.
  2. Try this

    var ballsContainer = document.getElementById(‘balls-container’);
    ballsContainer.style.removeProperty(‘height’);

    Login or Signup to reply.
  3. use
    $container.style.height = "";

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search