AngularJs element.height() not a function

前端 未结 2 1546
梦毁少年i
梦毁少年i 2020-12-19 00:22

I am trying to make a directive that would influence element width/height. Looking through examples I\'ve seen that you can get/set width/height by referencing appropriate f

2条回答
  •  旧巷少年郎
    2020-12-19 01:21

    Geoff Genz is correct that jqLite has no height() method or equivalent, but there is still a way to get the height of the selected element. Try this:

    var height = element[0].offsetHeight;
    

    element[0] returns the pure DOM element (without the jqLite wrapper) which has an offsetHeight property.

提交回复
热议问题