Change element display none back to default style value JS

前端 未结 6 996
伪装坚强ぢ
伪装坚强ぢ 2020-12-20 11:22

I have a function in JS that hides the element parsed:

function hide(id){
  document.getElementById(id).style.display = \"none\";
}

How can

6条回答
  •  独厮守ぢ
    2020-12-20 11:55

    Since what you want is the default value for the element and not what's in the style sheet, you simply want to set the value to auto.

    document.getElementById(id).style.display="auto"
    

    This tells the browser to calculate what the normal display for this type of element is and to use that.

提交回复
热议问题