Thread: Javascript loop
View Single Post

  #2 (permalink)  
Old 01-02-2008, 07:09 PM
davkell davkell is offline
Coder
 
Join Date: Jul 2007
Location: Galway
Posts: 66
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
davkell has much to be proud ofdavkell has much to be proud ofdavkell has much to be proud ofdavkell has much to be proud ofdavkell has much to be proud ofdavkell has much to be proud ofdavkell has much to be proud ofdavkell has much to be proud of
Default

Could you use something like:

PHP Code:
function change_font(what){ 
    var 
allSpans document.getElementById("yr").getElementsByTagName("span");
    for(
i=0allSpans.lengthi++)
    {
        
allSpans.item(i).style.fontSize "30";
    }
    
document.getElementById(what).style.fontSize "10"
    
document.getElementById(what).style.fontWeight "bold";
    
document.getElementById(what).style.color "#990000";


PHP Code:
<div id="yr">
    <
span id='yr123'>text</span>
    <
span id='yr1234'>text</span>
    <
span id='yr46545'>text</span>
    <
span id='yr897822'>text</span>
</
div
This will reset the styles of all spans, and then set the one chosen....or did I misunderstand what you're trying to do?
Reply With Quote