How to change css display none or block property u

2019-01-04 16:18发布

How to change css display none or block property using Jquery?

11条回答
小情绪 Triste *
2楼-- · 2019-01-04 16:31

use this

$("#id").(":display").val("block");

or

$("#id").(":display").val("none");
查看更多
三岁会撩人
3楼-- · 2019-01-04 16:34

The correct way to do this is to use show and hide:

$('#id').hide();
$('#id').show();

An alternate way is to use the jQuery css method:

$("#id").css("display", "none");
$("#id").css("display", "block");
查看更多
霸刀☆藐视天下
4楼-- · 2019-01-04 16:36

In my case I was doing show / hide elements of a form according to whether an input element was empty or not, so that when hiding the elements the element following the hidden ones was repositioned occupying its space it was necessary to do a float: left of the element of such an element. Even using a plugin as dependsOn it was necessary to use float.

查看更多
5楼-- · 2019-01-04 16:37

.hide() does not work in Chrome for me This works for hidding:

var pctDOM = jQuery("#vr-preview-progress-content")[0];
pctDOM.hidden = true;
查看更多
Explosion°爆炸
6楼-- · 2019-01-04 16:41

for hide:

$("#id").css("display", "none");

for show:

$("#id").css("display", "");
查看更多
啃猪蹄的小仙女
7楼-- · 2019-01-04 16:42

If the display of the div is block by default, you can just use .show() and .hide(), or even simpler, .toggle() to toggle between visibility.

查看更多
登录 后发表回答