Javascript examples for DOM HTML Element:Paragraph
Using Switch case to set various value for <p>
<html> <head></head> <body> <p id="para1"></p> <script> var i = 3; switch(i){/*from w w w .j av a 2s .c o m*/ case 1: { document.getElementById('para1').innerHTML = "The value is one."; break; } case 2: { document.getElementById('para1').innerHTML = "The value is two."; break; } case 3: { document.getElementById('para1').innerHTML = "The value is three."; break; } default:{ document.getElementById('para1').innerHTML = "The value is undefined." } } </script> </body> </html>