问题:
我正在尝试为 SVG 图条的高度设置动画:http: //jsfiddle.net/David_Knowles/pRTBt/
我的部分问题是.height()
返回0
,但.attr("height")
返回真实高度。
$(function(){
var $theBars = $("#v-bars").children();
var BarsHeight = $theBars.each(function(index, element ) {
var origHeight = $(this).attr("height");
console.log( index + ": " + $(this).attr("height"));
console.log( index + ": " + $(this).height());
});
});
我计划将高度设置为零并使用jquery.animate
何时触发高度动画eventHander
,但由于返回的高度问题似乎无法做到。
问题:
- 为什么
.height()
返回零? - 例如,单击时将原始高度应用回条形的最佳方法是什么?
编辑:部分解决方案 http://jsfiddle.net/David_Knowles/pRTBt/12/
可以编辑高度属性。这需要弄清楚如何将值数组传递给它