Menu ▼


For checking checkbox is checked or not using JQuery, we need to use the "prop" function. It will return the value "true" if check box is checked else returns "false".

Syntax: $("#chboption").prop("checked")

Example


Source Code

<html>
<head>
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script language="javascript">
        function IsCBSelected() {
            alert($("#chboption").prop("checked"));
        }       
    </script>
</head>
<body>
    <input type="checkbox" id="chboption" />
    <label for="chboption">
        Select this option</label>
    <br />
    <input type="button" onclick="IsCBSelected();" value="Test" />
</body>
</html>
Read More...
Submited By : mrkraju On 21 Sep 2014
           

Source Code :

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Blink Text using JavaScript</title></style>

    <script language="javascript">

        setInterval(blinktext, 500);

        var txt = "";

        var count = 0;

        function blinktext() {

            var cntrl = document.getElementById("txtblinkingtext");

            if (count == 0)

                txt = cntrl.value;

            if (count % 2 == 0)

                cntrl.value = "";

            else

                cntrl.value = txt;

            count++;

        }

    </script>

</head>

<body>

    <form id="form1" runat="server">

    <div style="margin: auto; text-align: center;">

        <input type="text" id="txtblinkingtext" name="txtblinkingtext" value="Blinking Text"

            readonly="readonly" style="height: 20px; width: 100px; background-color: Red;

            color: White; border: 0px none; text-align: center;">

    </div>

    </form>

</body>

</html>

 

 

Read More...
Submited By : mrkraju On 12 Nov 2013
We can create timer control by using JavaScript. setTimeout is the JavaScript in built function, which we can use to execute JavaScript Code after a specific time elapsed. The below timer control is generated by using JavaScript setTimeout function.
Below is the source code to generate the timer using JavaScript.

           


<html>

<head>

    <script language="javascript">

        var dt = null;

        setTimeout(setTime, 100);

        function setTime() {

            if (dt == null)

                dt = new Date();

            var totalseconds = parseInt(((new Date()) - dt) / 1000, 10);

            var hh = parseInt(totalseconds / (60 * 60), 10);

            var mm = parseInt((totalseconds - (hh * 60 * 60)) / 60, 10);

            var ss = parseInt(totalseconds - (hh * 60 * 60) - (mm * 60), 10);

            document.getElementsByName("txttimer")[0].value = (hh > 9 ? hh : ('0' + hh)) + ":" + (mm > 9 ? mm : ('0' + mm)) + ":" + (ss > 9 ? ss : ('0' + ss));

            setTimeout(setTime, 1000);

        }

    </script>

</head>

<body>

    <div style="margin: auto; text-align: center;">

        <input type="text" readonly="readonly" name="txttimer" style="text-align: center;

            color: Blue; font-weight: bold; border: solid 1px red; padding: 5px; width: 100px;

            height: 27px; margin: auto;" />

    </div>

</body>

</html>

Read More...
Submited By : mrkraju On 17 Oct 2013




Search dotnetlearners.com