Here is the reversed number-->
<!By GadTool>
<html>
<head>
<script>
function rev(){
var GT=document.getElementById("n").value;
var rev=0;
while(GT!=0){
document.getElementById("rev").innerHTML="Reversed Number="+rev+GT;
var GadTool=GT%10;
rev= rev*10+GadTool;
GT=GT/10;
GT=Math.floor(GT);
}
}
</script>
</head>
<body>
<input placeholder="Enter the Number" id="n"></input>
<button onclick="rev()">Reverse Number</button><br>
Here is the reversed number--><br>
<p id="rev"></p>
</body>
</html>
<html>
<head>
<script>
function rev(){
var GT=document.getElementById("n").value;
var rev=0;
while(GT!=0){
document.getElementById("rev").innerHTML="Reversed Number="+rev+GT;
var GadTool=GT%10;
rev= rev*10+GadTool;
GT=GT/10;
GT=Math.floor(GT);
}
}
</script>
</head>
<body>
<input placeholder="Enter the Number" id="n"></input>
<button onclick="rev()">Reverse Number</button><br>
Here is the reversed number--><br>
<p id="rev"></p>
</body>
</html>
First of all, we have to add to take input, here number, from the user. In the above example, we have given " n " as the id to the . Then, we have added a on clicking which, activates the function rev(). The is added for whenever the user has provided a number the number(input) can not be processed and reversed until has been clicked.
0 Comments