Jquery 如何在元素的每个子集内缩放值?

Jquery 如何在元素的每个子集内缩放值?,jquery,Jquery,我试图在每个.subgroup中重新缩放每个.totalInput的文本,并将其传递到“宽度”属性中,我该怎么做 $'div.subgroup'.eachfunctionindex,元素{ var maxLength=Math.max.applyMath,$.totalInput,this.mapfunction{ 返回$this.text; }.获得; $'.totalInput'.eachfunctionindex,元素{ var tot=元素; $element.sides.facet

我试图在每个.subgroup中重新缩放每个.totalInput的文本,并将其传递到“宽度”属性中,我该怎么做

$'div.subgroup'.eachfunctionindex,元素{ var maxLength=Math.max.applyMath,$.totalInput,this.mapfunction{ 返回$this.text; }.获得; $'.totalInput'.eachfunctionindex,元素{ var tot=元素; $element.sides.facet percentage.widthparseInt$element.text/maxLength+'%'; }; }; span{显示:内联块} 10 20 30 50 100 70
我相信这会满足你的要求:

$'div.subgroup'.eachfunction{ var maxLength=Math.max.applyMath,$this.find.totalInput.mapfunction{ return+$this.text; }.获得; $this.find'.facet percentage'.css'width',函数{ 返回100*+$this.next.text/maxLength+'%'; }.html; }; .分组{ 边框:1px纯蓝色; 框大小:边框框; 保证金:5px; } .子组>跨度{ 显示:块; 框大小:边框框; } .分面百分比{ 边框:1px纯红; } 10 20 30 50 100 70
如果我理解正确,您需要:

$'div.subgroup'.eachfunctionindex,元素{ var maxLength=Math.max.applyMath,$.totalInput,this.mapfunction{ 返回$this.text; }.获得; $this.children'.totalInput'.eachfunctionindex,元素{ var tot=元素; //console.logparseInt$tot.text/maxLength*100; $element.prev.facet percentage.css'width',parseInt$tot.text/maxLength*100+'%'; }; }; span.facet-percentage{显示:块;背景:红色;边距底部:10px;高度:10px;} .分组{ 宽度:600px; } 10 20 30 50 100 70
是否要将every.facet percentage的width属性设置为其后的第一个.totalInput的值?如果取决于宽度,请确保有span{display:inline block}`它应该取其中3个的最大值,然后重新缩放每个值。例如,第一组是10/30,20/30,30/30,并以百分比重新缩放。你的解释很难理解。也许您可以使用ASCII艺术绘制预期结果?请注意,在span元素上设置width属性没有任何作用;如果希望实际宽度发生更改,则需要设置style.width。