Vikas Vikas - 3 months ago 15
HTML Question

How to get position of the clicked element

I have a button, after user click a search form will be displayed over it.
Form is placed at the bottom inside footer.

I need to get button position (absolute, left, top).

This is my

html
entry:

<div><button class="search-button" type="button">Search<button></div>

Answer
 $(function() {
     $("#search-button").click(function() {
         var $clicker = $(this);
         var pos = $clicker.position();
         console.log(pos.top);
         console.log(pos.left);
     });
 });