find the length of string inside the div tag in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wahid Najmy
    New Member
    • Jan 2017
    • 1

    find the length of string inside the div tag in javascript

    see I have done this:
    I want to find the length of the string which is inside the div tag .
    Code:
            <script>
                function show_hide()
                {
                var l = getElementById("text").length;
      
                    alert(l);
              
                }
            </script>
           <div id="text"><p>I am the text which you want my length</p></div>
    Last edited by Dormilich; Jan 12 '17, 08:02 AM. Reason: please use code tags.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    have a look at the error console (F12). It will list your issues.

    Comment

    Working...