tags:

views:

34

answers:

3

Hello,

I have 4 DIV's with different ID's (but have same prefix (testDiv[1|2|3|4]) ) and i want to set their visblity(visible or hidden) on some event. How can i use to set the DIV visiblity property at one times something like

$('testDiv*').css('visibility', 'visible'); 
OR
$('testDiv*').css('visibility', 'hidden');

There is workaround to this problem. I can have a class named ".comnClass" for all the DIV's and change its property But i want a solution having four different DIV id.

THANKS ALL

+5  A: 
Sarfraz
+2  A: 
$('div[id^=testDiv]').attr('visibility', 'hidden');
Darin Dimitrov
THANKS Daren SarfarzIts not attribute but css
and its not visible but 'visiblity'
@user367134, yes it's `visibility`. Updated post.
Darin Dimitrov
Thank You Darin
+3  A: 

Having a common class is not the workaround. It is the right way to do it. The class establishes the relationship between these four elements so that you can manipulate them in a single go. The id is used to be able to identify them uniquely.

Noufal Ibrahim