How to create a random number in jquery

  By    Posted on January-12-2018   321


How to create a random number in jquery?


I have a web page, i have button, textbox, when user will click on "button" i want to create a random string and set that value in paragraph.


<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Create A random Number</title>
    <link rel="stylesheet" href="//">
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script src=""></script>
    <script src=""></script>

    <script language="javascript" type="text/javascript">
        function randomString()
            var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
            var string_length = 8;
            var randomstring = '';
            for (var i = 0; i < string_length; i++)
                var rnum = Math.floor(Math.random() * chars.length);
                randomstring += chars.substring(rnum, rnum + 1);
            return randomstring;


        $(document).ready(function ()





        function CreateNumber()





    <button class="generator" onclick="CreateNumber()">Genrate Random Number</button>
    <p class="ideaBox"></p>





By      12-Jan-2018 Views  321

You may also read following recent Post

Item Image
What are 3 C
Item Image
what is .net
Submit Post - Article - Ask a Question - Ask an Interview Question - Submit Useful Links