JavaScript Generate Random Quote
![]() |
| javascript random text rotator |
Hi Today we will Learn how To Rotate Different String In JavaScript.
You can Rotate any Sentece,Image or anything using This Method.
create 3 files named are given below.
1.index.html
2.script.js
3.style.css
![]() |
| javascript random quote generator |
Now Copy The Below Codes for Certain file.
<html> <head> <title>JavaScript Random Quote Generator</title> <link rel="stylesheet" href="style.css" type="text/css"/> <script src="script.js" type="text/javascript"></script> </head> <body> <table align="center"> <tr> <td> <b>Random Quote Generator</b> </td> </tr> <tr> <td id="add1">Click Next to Display Random message</td> </tr> <tr><td align="center"> <input type="button" value="Next Quote" border="0" onclick="rotate()"/></td></tr> </table> </body> </html>
var arr= new Array();
arr.push("Hrithik Rohsan -Bollywood Superstar");
arr.push("Mark Zukerbarg-Faceboob Founder");
arr.push("ANJAN KUMAR is Web Devoloper");
arr.push("Priyoshi is Singer");
function rotate()
{
var num= Math.round(Math.random()*3);
add(num);
}
function add(i)
{
var chi = document.createTextNode(arr[i]);
var tab1 = document.getElementById("add1");
while(tab1.hasChildNodes())
{
tab1.removeChild(tab1.firstChild);
}
tab1.appendChild(chi);
}
table{
border:1px solid green;
padding:16px;
width:40%;
height:30%;
border-collapse:collapse;
background: lightgreen;
}
input[type=button]{
padding:8px;
border-radius:5px;
background:black;
color:white;
}
Now You have successfully Created JavaScript Rotator System
Run index.html file to Get Result.



No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.