Twango Posted February 4, 2010 Share Posted February 4, 2010 Help!Does nothing!var pixls=0;while (pixls<=500){var pixels=pixls + "px";alert(pixels);pixls++;} Link to comment Share on other sites More sharing options...
justsomeguy Posted February 4, 2010 Share Posted February 4, 2010 I disagree, that loops and shows alert boxes. Link to comment Share on other sites More sharing options...
Twango Posted February 4, 2010 Author Share Posted February 4, 2010 why isnt this working?<html><body><script type="text/javascript">var pixls=0;while (pixls<=500){var pixels=pixls + "px";document.getElementById('bigger').style.fontSize=pixels;pixls++;}</script></body></html><b id="bigger" onclick="bigrs()">WOO</b> Link to comment Share on other sites More sharing options...
justsomeguy Posted February 4, 2010 Share Posted February 4, 2010 Maybe because the element you're trying to modify is not in the body, and also because that script executes before the element has been created, so the element doesn't even exist yet by the time you try to modify it. Link to comment Share on other sites More sharing options...
just2comment Posted February 5, 2010 Share Posted February 5, 2010 By the way, <b id="bigger" onclick="bigrs()">WOO</b> is "outside" the whole document because it is after </html>? Link to comment Share on other sites More sharing options...
Ingolme Posted February 5, 2010 Share Posted February 5, 2010 You have another problem as well: var pixels=pixls + "px"; By using var you're declaring a variable. You can only do this once, if you try to declare a variable that already exists, an error will be thrown. Each time the loop iterates, it's trying to declare the variable again. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.