how to retrieve value of "top" on an element

Brad Bansner
Brad Bansner used Ask the Experts™
on
I'm moving the element displayscreens around and need to know if it exceeds a certain amount (see code attached). So I'm trying to read the value of "top" like this:

if ($('#displayscreens').attr('top')==2484)

But it isn't working. So I added an alert:

lert($('#displayscreens').attr('top'));

That keeps telling me "undefined". How can I figure the "top" value so I know how far the user has moved #displayscreens? Thank you!
$('#gr_mwc_arrowleft').click(function(){
	alert($('#displayscreens').attr('top'));
	if ($('#displayscreens').attr('top')==2484) {
	} else {
		$('#displayscreens').animate({top: '+=414px'}, 1000);
	}
});

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2015
Commented:
$('#displayscreens').offset().top;
Brad BansnerWeb Developer

Author

Commented:
Excellent, thanks!
Top Expert 2015

Commented:
You're welcome, thanks for the points.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial