| | document.getElementById e document.getElementsByTagName + ciclo for | |
| |
| | |
| max_400 |
| | document.getElementById e document.getElementsByTagName + ciclo foroltre a dare un azione ad un indentificatore ID lo possiamo fare anche con il nome del tagcontrollare i bordi CODICE <style> .banana{ border: 5px solid #ff0000; width: 200px; } </style>
<script> function bordo(){ document.getElementById('bersaglio').className='banana'; } </script>
--------------Questo con getElementByID---------------------------<br> <p id="bersaglio">hhhhhh</p>
<input type="button" onclick="bordo()" value="bordo"> <input type="button" onclick="location.reload()" value="togli bordo"><br>
---------oppure tutti i paragrafi con contorno-----con--document....tagName--------------<br>
<script> function bordi(){ totale=5; i=0; for(i=0;i<=totale;i++){ document.getElementsByTagName('p').item(i).className='banana'; } } </script>
<p>aaa</p> <p>bbb</p> <p>ccc</p>
<input type="button" onclick="bordi()" value="bordi"> <input type="button" onclick="location.reload()" value="togli bordo"><br> Ed ecco l'esempio http://max400.netne.net/document_get_Eleme..._e_tagName.htmlPS per sbrigarmi prima ho usato il reload... ih ih ih
| | |
| |
|
| 0 replies since 5/4/2012, 02:08 100 views |
| |
| | |