Shoutbox

am i blind? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: am i blind? (/showthread.php?tid=75914)

am i blind? by Supersonicdarky on 07-07-2007 at 01:35 AM

there's obviously something wrong here that i am not seeing >.<

code:
<html>
    <head>
        <title>Moo</title>
       
        <style type="text/css">
       
            a {
                color: #666;
                text-decoration: underline;
                font-weight: normal;
            }
       
            #box {
                width: 400px;
                padding: 15px;
                border: 1px #333 solid;
                background: #ccc;
                margin: 15px;
            }
           
            #box h1 {
                font-size: 24px;
                margin: 5px;
            }
           
            #box p {
                margin: 5px;
                font-size: 14px;
                line-height: 1.4;
            }
           
            #box p span {
                border-bottom: 1px #666 dotted;
            }
       
        </style>
       
        <script language="javascript">
       
        function fontsize(px) {
            document.getElementById('foo').style.font-size=px;
        }
       
        </script>
       
    </head>
   
    <body>
   
        <h3>Font Size: <a href="#" onClick="fontsize('12px')">Small</a> | <a href="#" onClick="fontsize('16px')">Medium</a> | <a href="#" onClick="fontsize('20px')">Large</a></h3>
   
        <div id="box">
            <h1>Box 1</h1>
            <p>Maecenas dapibus mi non nunc. <span id="foo">Curabitur</span> sed ipsum feugiat tellus ultricies accumsan. Integer pretium, orci sit amet ultricies blandit, augue felis volutpat enim, ut sodales lacus diam et sapien. Phasellus pellentesque. In fringilla ante id magna <span id="foo">commodo</span> dictum. Maecenas dapibus malesuada neque. Morbi tincidunt augue eu ligula. Donec dignissim. Etiam rhoncus. Nam id sapien. Pellentesque auctor venenatis massa. Donec eleifend sodales orci. Mauris non mauris. Quisque non velit.</p>
        </div>
       
        <div id="box">
            <h1>Box 2</h1>
            <p>Etiam in justo. Fusce ut mi at justo aliquet <span id="foo">cursus</span>. Cras orci felis, iaculis nec, placerat vulputate, sollicitudin fermentum, nibh. Nullam accumsan enim et velit. Integer arcu turpis, congue et, fermentum quis, tincidunt sed, ipsum. Proin sagittis varius mi. In mollis placerat mi. Duis ornare sem ut lectus. Donec porttitor sollicitudin neque. Quisque aliquet. Sed ornare. <span id="foo">Nunc</span> varius. Morbi pretium est non lectus.</p>
        </div>
       
    </body>
</html>

nothing happens when i click the font size links >.<
RE: am i blind? by WDZ on 07-07-2007 at 01:46 AM

style.font-size
style.fontSize


RE: am i blind? by Supersonicdarky on 07-07-2007 at 01:53 AM

w3wt!

but it only changes size of first <span></span> =/


RE: am i blind? by WDZ on 07-07-2007 at 02:22 AM

Yeah, id attributes need to be unique, so you can't have two elements with id="foo" on the same page.

You could change id="foo" to class="foo" and then use a loop like this to go through them all...

code:
function fontsize(px) {
    var spanElements = document.getElementsByTagName('span');
    for(var i = 0; i < spanElements.length; i++) {
        if(spanElements[i].className == 'foo') {
            spanElements[i].style.fontSize = px;
        }
    }
}

RE: am i blind? by Supersonicdarky on 07-07-2007 at 02:55 AM

w3wt!

* Supersonicdarky sexes dz w/out protection

8-)

---

test

&#12398;

&#12364;

&#12399;

&#12392;

&#12395;

&#12434;


RE: am i blind? by Voldemort on 07-07-2007 at 03:15 AM

ewww
no unicode


RE: am i blind? by Supersonicdarky on 07-07-2007 at 03:17 AM

i know, i pasted unicode here so it would get converted


RE: am i blind? by Voldemort on 07-07-2007 at 03:24 AM

ahaha