0

This plunk is my attempt to convert an HTML table to a Javascript array using only AngularJS/jqLite. I can get the head and body from the table, however when I try to get the rows from the body object I get the following error (see the console): tbody.children is not a function. How to fix this?

Javascript

      var table = angular.element($scope.t);
      var thead = table.children()[0];
      var tbody = table.children()[1];

      console.log(tbody.children());

1 Answer 1

2

I've not used this API before, but a quick check reveals that you lose the angular.element benefits when you pick the children(). You can wrap it again like this to access children method again:

  var table = angular.element($scope.t)
  var thead = angular.element(table.children()[0])
  var tbody = angular.element(table.children()[1])

  console.log(tbody.children());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.