Monday 19 December 2016

how set and get the innerHTML of the Label and DIV control using jQuery or JavaScript

Description:

In this example we explain that how set and get the innerHTML of the Label and DIV control using jQuery or JavaScript. Or how to replace the innerHTML of the div using jQuery or javascript.

Code:

<html>
<head>
    <title>Windows forms => Web forms</title>
    <head>
        <script type="text/javascript" src="jquery1.8.3-min.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript">
            // get and set using jquery
            $(document).ready(function () {

                $("#jqerr").html("Div is Fill up by jQuery.");
                var title = $('#jqerr').html();
                alert(title);

                // get and set using javascript
                // Get the text content:

                alert(document.getElementById("jerr").textContent);
                // Set the text content:
                document.getElementById("jerr").textContent = "This is some text";
            });

          
        </script>
    </head>
    <body>
        <div id="jqerr">
            jQuery DIV
        </div>
        <div id="jerr">
            JavaScript DIV
        </div>
    </body>
</html>


0 comments:

Post a Comment