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);
}
}());
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);
}
}());
Share
Improve this question
asked Jul 25, 2016 at 5:14
Fred J.Fred J.
6,04913 gold badges60 silver badges113 bronze badges
3
-
1
DOM nodes don't have a
width
property. Did you mean offsetWidth? – John Dvorak Commented Jul 25, 2016 at 5:18 - use .width() property. – Ronak Patel Commented 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 Commented Feb 14, 2017 at 14:20
1 Answer
Reset to default 5Use the event.currentTarget.offsetWidth
property instead of width
.