Find (x, y) or (top, left) location of a textbox or button using jquery

I am using jquery in my php webpage. I want to find the location of a textbox or button on a page. Please give me a jquery sample to find this. Please provide any suggestions you have. Thanks in advance.

+2


source to share


2 answers


See jQuery Offset . It gets the current offset of the matched element, in pixels, relative to the document.

var textbox = jQuery("#element");
var offset = textbox.offset();
console.log("left: " + offset.left + ", top: " + offset.top );

      



See also: selector / text and selector / button

Use Firebug . It also adds a global variable named "console" to all web pages loaded in Firefox. In this case, "console.log" writes a message to the console.

+4


source


See positioning in the jQuery API CSS page



+1


source







All Articles