![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
The task seems simple but I am not sure whether this is possible or even the right way to look at it... I have <td class="X"> elements where "X" is a placeholder for class names "A", "B", etc. Now I want to display/hide all <td> elements of a certain class, say "A". The static CSS equivalent would be style type="text/css" .A { visibility:visible; } .B { visibility:hidden; } ... /style but is it possible to dynamically change the visibility attribute for all td> elements of a certain class "A" using javascript in a simple way? |
#3
| |||
| |||
|
|
* Janis Papanagnou wrote in comp.lang.javascript: The task seems simple but I am not sure whether this is possible or even the right way to look at it... I have <td class="X"> elements where "X" is a placeholder for class names "A", "B", etc. Now I want to display/hide all <td> elements of a certain class, say "A". The static CSS equivalent would be style type="text/css" .A { visibility:visible; } .B { visibility:hidden; } ... /style but is it possible to dynamically change the visibility attribute for all td> elements of a certain class "A" using javascript in a simple way? You can add/remove/enable/disable/change a special <style> element with the desired rules; if you have very many matching elements that'll most likely be the fastest approach. |
#4
| |||
| |||
|
|
You can add/remove/enable/disable/change a special <style> element with the desired rules; if you have very many matching elements that'll most likely be the fastest approach. Thanks for your quick reply. As a (quite) newbie on the topic I seem to be still missing something fundamental that is likely apparent to you. |
#5
| |||
| |||
|
|
The task seems simple but I am not sure whether this is possible or even the right way to look at it... I have <td class="X"> elements where "X" is a placeholder for class names "A", "B", etc. *Now I want to display/hide all <td> elements of a certain class, say "A". The static CSS equivalent would be * * * * *<style type="text/css" * * * * * * * * *.A { visibility:visible; } * * * * * * * * *.B { visibility:hidden; } * * * * * * * * *... * * * * *</style but is it possible to dynamically change the visibility attribute for all td> elements of a certain class "A" using javascript in a simple way? I mean, something syntactic simple like the pseudo code * * * * *document.<whatever("A")>.visibility = hidden; Or do I have to iterate over the DOM tree and compare each element against the class name? Any hints very much appreciated. -- Janis |
#6
| |||
| |||
|
|
The task seems simple but I am not sure whether this is possible or even the right way to look at it... I have <td class="X"> elements where "X" is a placeholder for class names "A", "B", etc. Now I want to display/hide all <td> elements of a certain class, say "A". The static CSS equivalent would be style type="text/css" .A { visibility:visible; } .B { visibility:hidden; } ... /style but is it possible to dynamically change the visibility attribute for all <td> elements of a certain class "A" using javascript in a simple way? I mean, something syntactic simple like the pseudo code document.<whatever("A")>.visibility = hidden; Or do I have to iterate over the DOM tree and compare each element against the class name? Any hints very much appreciated. |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
Thanks to all for your suggestions; they are very helpful! :-) |
#9
| |||
| |||
|
|
On Sun, 15 Jun 2008 18:42:56 +0200, Janis Papanagnou wrote: Thanks to all for your suggestions; they are very helpful! :-) Here's one more: quote part of the message to which you are replying. |
|
It makes it much easier to follow the discussion (especially for people who aren't veiwing the posts threaded). |
#10
| |||
| |||
|
|
but is it possible to dynamically change the visibility attribute for all td> elements of a certain class "A" using javascript in a simple way? |
![]() |
| Thread Tools | |
| Display Modes | |
| |