使用javascript获取选项元素的高度? [英] Getting the height of an option element with javascript?

查看:108
本文介绍了使用javascript获取选项元素的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像往常一样,当一个select元素被点击并且我想获得选项元素的高度时,会显示选项元素。



谢谢。 >

编辑 @david 旧学校



 < select> 
< option> a< / option>
< option> s< / option>
< / select>


解决方案

我相信这是你想要的

  $(document).ready(function(){
$(#mySelect)。 b $ b alert($(this.options [this.selectedIndex])。height());
});
});

这里是 demo http://jsfiddle.net/xf3wD/


As usual, option elements are shown when a select element is clicked and I'd like to get the height of the option elements.

Thanks.

Edit @david old school select

<select>
<option>a</option>
<option>s</option>
</select>

解决方案

I believe this is what you want

$(document).ready(function () {
  $("#mySelect").change(function () {
    alert($(this.options[this.selectedIndex]).height());
  });
});

Here is a demo http://jsfiddle.net/xf3wD/

这篇关于使用javascript获取选项元素的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆