Waffeloo wrote:
Hi,
I would like an event to trigger a change the style of all the elements that
belong to some CSS class.
I know it is possible to change the class of an element, for example with:
<script language=javasc ript>
function changeclass()
{document.getEl ementById(id).c lassName="class _id";}
</script>
<input type=checkbox onclick="javasc ript:changeclas s()">
function changeclass(ele m,newClass)
{document.getEl ementById(elem) .className=newC lass;}
</script>
<input type=checkbox onclick="javasc ript:changeclas s('div_1','spec _9')">
But this can only change one element. I would like to change the
"property:l ist" pairs of a CSS class, so that changes can apply to more
than one element.
Is it possible with javascript?
I think you can't modiy properties of a class defined
(except, perhaps with IE and sheetStyle.rule s ?)
You can catch all tags collection of the page
and for each tag with a certain class, change it :
var D = document.getEle mentsByTagName( '*');
for(var i=0;i<D.length; i++)
if(D[i].className=='tr uc') D[i].className="tri ck";
of course you need 2 classes
of course you need your elements have a class
(it is not always)
you may also search lists elements and change their styles
var L = document.getEle mentsByTagName( 'UL')
for(var i=0;i<L.length; i++)
if(L[i].style.textDeco ration=='none') D[i].style.textDeco ration='underli ne';
--
Stephane Moriaux et son [moins] vieux Mac