如何使用 jquery 将元素的宽度增加 10rem。问题是 Jquery 总是以像素为单位返回宽度/高度,我们希望以其他一些单位更新高度/宽度。
示例:JS Bin
var $c = $('#container');
console.log($c.width());
var c = document.getElementById('container');
// Q1. Why is it different from above one. This is 324 while earlier it was 320. See the output.
console.log(c.clientWidth);
// Q2. How to update the code to increase the width by 10rem.
$c.css({width: $c.width() + 10}); //It adds 10 pixels here.
console.log($c.width());
我的问题是代码中的注释。