textContent not working with IE7/8

2 posts, 1 answers
  1. Ian
    Ian avatar
    129 posts
    Member since:
    Jun 2009

    Posted 02 Aug 2012 Link to this post

    Hi,
    I've been using the suggested method of testing the textContent property when a tab is selected to identify the new current tab.. It works fine with Chrome, FF, IE9 but the textContent property appears to be undefined with IE7/8. Example code below. is this a bug?:

    <!DOCTYPE html>
    <html>
    <head>
      <title></title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
      <script type="text/javascript" src="http://cdn.kendostatic.com/2012.2.710/js/kendo.web.min.js"></script>
        <link href="http://cdn.kendostatic.com/2012.2.710/styles/kendo.common.min.css" rel="stylesheet" />
      <link href="http://cdn.kendostatic.com/2012.2.710/styles/kendo.default.min.css" rel="stylesheet" />
    </head>
    <body>
        
      <div id="example" class="k-content">
            <div id="tabStrip">
                <ul>
                    <li class="k-state-active">
                        Paris
                    </li>
                    <li>
                        New York
                    </li>
                    <li>
                        London
                    </li>
                </ul>
            </div>
        </div>

      <script type="text/javascript">
          $(document).ready(function () {
              var tabstrip = $("#tabStrip").kendoTabStrip({
                  select: onSelect
              });
          });

          function onSelect(e) {
              alert(e.item.textContent);
          }
      </script>
    </body>
    </html>

    Regards, Ian
  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 06 Aug 2012 Link to this post

    Hi Ian,

     Indeed textContent is not supported by IE7/8. The latter has a different property called innerText which returns the text contents of a DOM node.
     
     Here is how to use both:

    var text  = e.item.textContent || e.item.innerText;
    alert(text);

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
Back to Top