javascript - change css using JS -
i trying call js event, depending on button press, (there 3 buttons) want css change font-size (differently each button), have not work. can help?
body { background-image: url("back2.jpg"); background-size: 100% 100%; } .buttonsize1{ font-size: 3px; } .buttonsize2{ font-size: 26px; } .buttonsize3{ font-size: 45px; } .fixed { position: fixed; top: 100px; left: 0px; width: 150px; border: #0e6b5b 3px solid; background-color: #ff9933; } p { padding-left: 100px; } td { padding-top: 10px; padding-bottom: 50px; text-align: center; font-family: "lucida console", monaco, monospace; } .opac { opacity: 0.5; filter: alpha(opacity=10); /* ie8 , earlier */ } .opac:hover { opacity: 1.0; filter: alpha(opacity=100); /* ie8 , earlier */ } .maintable{ border: #0e6b5b 3px solid; background-color: #ff9933; width: 50%; padding-top: 10px; padding-left: 100px; padding-right: 100px; } table.center { width:70%; margin-left:15%; margin-right:15%; }
<!doctype html> <html> <head> <link rel="stylesheet" href="7global.css"/> <title> csgo </title> <script> function textsizes(){ document.getelementbyid("maintbl").style.font-size = "3px"; } function textsizem(){ document.getelementbyid("maintbl").style.font-size = "26px"; } function textsizel(){ document.getelementbyid("maintbl").style.font-size = "45px"; } </script> </head> <body> <table class = "fixed opac"> <tr> <td><a href="index.html">home</a> </td> </tr> <tr> <td><a href="3maps.html">maps</a> </td> </tr> <tr> <td><a href="4ct.html">counter <br/> terrorists</a> </td> </tr> <tr> <td><a href="5t.html">terrorists</a> </td> </tr> <tr> <td><a href="6about.html">about</a> </td> </tr> <tr> <td><button class="buttonsize1" onclick="textsizes()">a</button> <button class= "buttonsize2" onclick="textsizem()">a</button> <button class= "buttonsize3" onclick="textsizel()">a</button></td> </tr> </table> <br/> <br/> <br/> <table id = "maintbl" class = "maintable center"> <td> cs:go’s next major </td> <tr> <td> europe region – hosted dreamhack </td> </tr> </table> <table id = "maintbl" class = "maintable center"> <td> operation wildfi </td> <tr> <td> what’s new? visit page below details! </td> </tr> </table> <table id = "maintbl" class = "maintable center"> <td> made adjustments rifles recently... </td> <tr> <td> ncs:go. m </td> </tr> </table> </body> </html>
like this, added wrapper div set font size to, corrected syntax error ...style.font-size
...style.fontsize
, removed duplicated id's (as should unique).
function textsizes(){ document.getelementbyid("maintblwrapper").style.fontsize = "3px"; } function textsizem(){ document.getelementbyid("maintblwrapper").style.fontsize = "26px"; } function textsizel(){ document.getelementbyid("maintblwrapper").style.fontsize = "45px"; }
body { background-image: url("back2.jpg"); background-size: 100% 100%; } .buttonsize1{ font-size: 3px; } .buttonsize2{ font-size: 26px; } .buttonsize3{ font-size: 45px; } .fixed { position: fixed; top: 100px; left: 0px; width: 150px; border: #0e6b5b 3px solid; background-color: #ff9933; } p { padding-left: 100px; } td { padding-top: 10px; padding-bottom: 50px; text-align: center; font-family: "lucida console", monaco, monospace; } .opac { opacity: 0.5; filter: alpha(opacity=10); /* ie8 , earlier */ } .opac:hover { opacity: 1.0; filter: alpha(opacity=100); /* ie8 , earlier */ } .maintable{ border: #0e6b5b 3px solid; background-color: #ff9933; width: 50%; padding-top: 10px; padding-left: 100px; padding-right: 100px; } table.center { width:70%; margin-left:15%; margin-right:15%; }
<table class = "fixed opac"> <tr> <td><a href="index.html">home</a> </td> </tr> <tr> <td><a href="3maps.html">maps</a> </td> </tr> <tr> <td><a href="4ct.html">counter <br/> terrorists</a> </td> </tr> <tr> <td><a href="5t.html">terrorists</a> </td> </tr> <tr> <td><a href="6about.html">about</a> </td> </tr> <tr> <td><button class="buttonsize1" onclick="textsizes()">a</button> <button class= "buttonsize2" onclick="textsizem()">a</button> <button class= "buttonsize3" onclick="textsizel()">a</button></td> </tr> </table> <br/> <br/> <br/> <div id = "maintblwrapper"> <table class = "maintable center"> <td> cs:go’s next major </td> <tr> <td> europe region – hosted dreamhack </td> </tr> </table> <table class = "maintable center"> <td> operation wildfi </td> <tr> <td> what’s new? visit page below details! </td> </tr> </table> <table class = "maintable center"> <td> made adjustments rifles recently... </td> <tr> <td> ncs:go. m </td> </tr> </table> </div>
Comments
Post a Comment