设置图像可见性为假。

时间:2023-01-17 15:08:29

I have many images that are all part of one class, here is the code:

我有很多图像都是一个类的一部分,这里是代码:

class='button_cell'

Can I please have some help to set all of these images to not be visible via Javascript?

我能不能帮你把所有这些图片都设置为不可见的Javascript?

I use the following code to set all items in a DIV to be disabled:

我使用以下代码将DIV中的所有项设置为禁用:

$('#incident_div').find('input, textarea, button, select').attr('disabled',true);

I am guessing that the code should be similar, yet I am stuck.

我猜代码应该是类似的,但我还是卡住了。

May I please have some help with this?

我可以帮忙吗?

4 个解决方案

#1


1  

You can select all of the images in the button_cell class using $('.button_cell') and then use the hide() function to hide them all, like so:

您可以使用$('.button_cell')选择button_cell类中的所有图像,然后使用hide()函数来隐藏它们,比如:

$('.button_cell').hide();

#2


1  

I'm not sure exactly what you want, if you want to hide them use:

我不确定你想要什么,如果你想隐藏他们使用:

$('#incident_div').find('input, textarea, button, select').hide();

If you want to hide elements with class 'button_cell' you can use

如果您想要隐藏带有类“button_cell”的元素,您可以使用。

 ('button_cell').hide()

If you just want to disable them as in grey them out try:

如果你只是想让他们在灰色中禁用,那就试试:

$('#incident_div').find('input, textarea, button, select').each(function(){
    $(this).attr("disabled",true);
});

Here is a working fiddle: http://jsfiddle.net/XfVvf/

这里有一个工作的小提琴:http://jsfiddle.net/xfvf/。

#3


0  

To hide by class:

隐藏类:

$('.button_cell').hide();

This will select all elements of class "button_cell" and hide them.

这将选择类“button_cell”的所有元素并隐藏它们。

Similarly, to show them:

同样,告诉他们:

$('.button_cell').show();

Reading: jQuery selectors

阅读:jQuery选择器

#4


0  

This is a good start, but without seeing more it is hard to know...

这是一个好的开始,但是如果没有更多的了解,就很难知道……

$('.button_cell').show();

I did show instead of hide because you said you want them to not be invisible...which means visible.

我做的是展示而不是隐藏,因为你说你希望他们不是隐形的……这意味着可见。

If in fact you would like them to be invisible use:

如果你希望它们是无形的:

$('.button_cell').hide();

#1


1  

You can select all of the images in the button_cell class using $('.button_cell') and then use the hide() function to hide them all, like so:

您可以使用$('.button_cell')选择button_cell类中的所有图像,然后使用hide()函数来隐藏它们,比如:

$('.button_cell').hide();

#2


1  

I'm not sure exactly what you want, if you want to hide them use:

我不确定你想要什么,如果你想隐藏他们使用:

$('#incident_div').find('input, textarea, button, select').hide();

If you want to hide elements with class 'button_cell' you can use

如果您想要隐藏带有类“button_cell”的元素,您可以使用。

 ('button_cell').hide()

If you just want to disable them as in grey them out try:

如果你只是想让他们在灰色中禁用,那就试试:

$('#incident_div').find('input, textarea, button, select').each(function(){
    $(this).attr("disabled",true);
});

Here is a working fiddle: http://jsfiddle.net/XfVvf/

这里有一个工作的小提琴:http://jsfiddle.net/xfvf/。

#3


0  

To hide by class:

隐藏类:

$('.button_cell').hide();

This will select all elements of class "button_cell" and hide them.

这将选择类“button_cell”的所有元素并隐藏它们。

Similarly, to show them:

同样,告诉他们:

$('.button_cell').show();

Reading: jQuery selectors

阅读:jQuery选择器

#4


0  

This is a good start, but without seeing more it is hard to know...

这是一个好的开始,但是如果没有更多的了解,就很难知道……

$('.button_cell').show();

I did show instead of hide because you said you want them to not be invisible...which means visible.

我做的是展示而不是隐藏,因为你说你希望他们不是隐形的……这意味着可见。

If in fact you would like them to be invisible use:

如果你希望它们是无形的:

$('.button_cell').hide();