Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用变量将元素设置为百分比宽度?
var progBarValue = $('.days-due').text(); $('.bar').width(progBarValue%);
该值是一个字符串,因此您只需将百分号附加到它。
var width = parseInt(progBarValue); if (width > 100) { width = 100; } $('.bar').width(width +"%");