【发布时间】:2015-11-14 17:54:14
【问题描述】:
Varinder 的This answer 效果很好,但我想获得以像素为单位设置的元素宽度并将其增加 10%。
$(window).load(function() {
$(".ml").each(function() { // this is kindof sugary way of doing for loop over array of elements - which is $(".ml")
var $this = $(this); // the current jQueried .ml element
var currentWidth = $this.width(); // get width of current element, width is a jQuery method: https://api.jquery.com/width/
var newWidth = currentWidth + 5; // increment the width
$this.width(newWidth); // pass in the new width as the parameter.
});
});
【问题讨论】:
标签: javascript jquery width percentage