Search code examples
backbone.jsmarionettechildrendocument-body

Backbone.js - get childElementCount value in devTools to print


I trying to log childElementCount property in chrome dev tools but I get undefined.

this is my code:

console.log('childElementCount---', this.ui.tbody.get('childElementCount')

returns childElementCount--- undefined

why is it undefined?

img1


Solution

  • jQuery get() is for retrieving the underlying DOM element from the jQuery object. It accepts an integer index instead of a string. Try this.ui.tbody.get(0).childElementCount or this.ui.tbody.get(0).getAttribute('childElementCount')

    or withjQuery:

    this.ui.tbody.prop('childElementCount') or this.ui.tbody.children().length