我遇到了这个问题:根据我想创建条形图的数字。有趣的是,它在 IE8 的怪癖模式下运行良好,但在其他任何地方都失败了。我真的不能说错误在哪里,我希望这里有人可以帮助我。我正在使用 jQuery,但使用 getElementById() 和 element.style.width = Somevalue(即没有 jQuery)也不起作用:(
[编辑:删除了完整的示例链接;馅饼过期了。]
基本上:
<input onChange="calculateField(1)" ...>
function calculateField(fieldname){
value = $("#input_" + fieldname).val();
fancyMagic();
value = 6 * value; // for testing
$("#subtotal_" + fieldname).html(value);
updateDiagram();
}
function updateDiagram(){
// gather required into, maxwidth, maxval, etc...
// fetch 'normal' bar
var target = $("#animatebar_1");
var width = maxwidth * (value / maxval);
// set width to proper width
target.width(width);
// like for avg bar
var avgtarget = $("#avgbar_1");
var avgwidth = maxwidth * (averagevalue / maxval);
avgtarget.width(avgwidth);
}
我在各种设置和 Opera 中尝试了所有 FF、IE8,但它根本不起作用。栏的宽度在之后立即设置为零。有趣的是,IE8 怪癖模式有效。
我很确定这只是我愚蠢,但我会很感激这方面的帮助。我也尝试使用 .css() 来更改大小,但它也不起作用。
非常感谢您提前。