user2023359
user2023359

Reputation: 289

Set images visibility to be false

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?

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

$('#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?

Upvotes: 1

Views: 927

Answers (4)

BlueBird
BlueBird

Reputation: 1466

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();

Upvotes: 0

Benjamin Gruenbaum
Benjamin Gruenbaum

Reputation: 276306

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').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/

Upvotes: 1

Benjamin
Benjamin

Reputation: 749

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').hide();

Upvotes: 1

MikeSmithDev
MikeSmithDev

Reputation: 15797

To hide by class:

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

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

Similarly, to show them:

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

Reading: jQuery selectors

Upvotes: 0

Related Questions