带有变量的 jQuery 分区

标签 jquery css width divide

我是 jQuery 的新手,想知道是否可以获取一些变量并将它们的除法作为 CSS 宽度。到目前为止我在这里:

var x = $(".some-container").length;
var y = $("#some-div").width();
$(".container").css("width", "x / y");

感谢您的帮助!

最佳答案

$(".container").css("width", (x / y));

$(".container").css("width", function(){
 return (x / y);
});

关于带有变量的 jQuery 分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22910783/

相关文章:

javascript - 如何从 Bootstrap 4 上的复选框按钮检索值?

javascript - 渐进式宽度调整 : is this for aesthetic or technical reasons?

javascript - 通过CSS在div中组合文本

jqgrid - 我正在使用 jqGrid 并希望在调整列宽后保存列宽

JavaGUI : Box layout with width fit to container?

javascript - 如何将div粘贴到父div的顶部

php - 调用函数并运行它

javascript - 脚本在 div tabbertab 中未正确显示

jquery - 在两个特定像素点之间滚动

html - 当 flexbox 元素以列模式包装时,容器不会增加其宽度