jQuery & CSS - Remove/Add display:none

前端 未结 13 2333
遥遥无期
遥遥无期 2020-12-12 12:37

I have a div with this class :

.news{
  width:710px; 
  float:left;
  border-bottom:1px #000000 solid;
  font-weight:bold;
  display:none;
}
<
13条回答
  •  执笔经年
    2020-12-12 12:54

    The only way to remove an inline "display:none" via jQuery's css-api is by resetting it with the empty string (null does NOT work btw!!).

    According to the jQuery docu this is the general way to "remove" a once set inline style property.

    $("#mydiv").css("display","");

    or

    $("#mydiv").css({display:""});

    should do the trick properly.

    IMHO there is a method missing in jQuery that could be called "unhide" or "reveal" which instead of just setting another inline style property unsets the display value properly as described above. Or maybe hide() should store the initial inline value and show() should restore that...

提交回复
热议问题