Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I grab the width and height for a currentTarget in jquery?

I'm trying to get the width and height of target when I click on it. event.currentTarget.width or event.currentTarget.width() (same for height) is not working. Any ideas on how to obtain the current targets width and height?

like image 414
DMar Avatar asked Dec 27 '22 21:12

DMar


1 Answers

If you want to use the jQuery methods you need to wrap the elements, e.g.:

$(event.currentTarget).width()

Otherwise you're stuck with using whatever DOM properties your browser supports, e.g..

event.currentTarget.offsetWidth
like image 140
Alnitak Avatar answered Jan 30 '23 01:01

Alnitak