使用另一个元素的高度

时间:2012-01-01 03:33:45

标签: jquery

我目前正在尝试使用jQuery滑块来使用div的百分比高度。

我的HTML页面中的常用代码是:

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

和.js:

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

我的问题是,不是用“这个”来获得高度,我如何从另一个div获得它,说“#basis”?

我尝试了一些东西,但我是jQuery的新手,这只是一个快速的问题。 谢谢您的帮助。如果您需要更多信息,请告诉我。

2 个答案:

答案 0 :(得分:3)

只需使用jQuery的height方法:

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

这是小提琴:http://jsfiddle.net/tdwEM/

答案 1 :(得分:1)

试试

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

请参阅http://api.jquery.com/height/

相关问题