4

This meteor client code needs the width of the element for which the event happened but failed to get it. How can it be done? Thanks

Template.swipe.events({
  'mouseup .swipe': function(e) {
    utility.mouseUp(e);
  }
});

utility = (function () {

  return {
    mouseUp: (event) => {
      console.log(event.currentTarget.width);
    }
}());
3
  • 1
    DOM nodes don't have a width property. Did you mean offsetWidth? Jul 25, 2016 at 5:18
  • use .width() property. Jul 25, 2016 at 5:22
  • @JanDvorak - offsetWidth wasn't the solution for me. However your link revealed the correct property I was searching for: scrollWidth. Just in case someone else has the same problem!
    – MerlinK
    Feb 14, 2017 at 14:20

1 Answer 1

5

Use the event.currentTarget.offsetWidth property instead of width.

1

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.