This is a migrated thread and some comments may be shown as answers.

textContent not working with IE7/8

1 Answer 59 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 02 Aug 2012, 12:59 PM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 06 Aug 2012, 03:24 PM
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!
Tags
TabStrip
Asked by
Ian
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or