Jordan
Jordan

Reputation: 23

Using the height of another element

I'm currently trying to get a jQuery slider to use the percentage height of a div.

The usual code in my HTML page is:

window.f = new x.slider('#slider1', {...options...});

And the .js:

x.slider = function(elem, opts)
...
var _this = this;
this.element = $(elem);
this.height = this.options.height ? this.options.height : null;

My question is, rather than using "this" to get the height from, how would I get it from another div, say "#basis"?

I've tried a few things, but I'm new to jQuery, and this is only a quick problem. Thank you for your help. Please do tell me if you need more information.

Upvotes: 2

Views: 77

Answers (2)

Gabriel Santos
Gabriel Santos

Reputation: 4974

Just try

$("#basis").height();

See http://api.jquery.com/height/

Upvotes: 1

Joseph Silber
Joseph Silber

Reputation: 219920

Simply use jQuery's height method:

$('#basis').height();

Here's the fiddle: http://jsfiddle.net/tdwEM/

Upvotes: 3

Related Questions