【问题标题】:jQuery Division with variables带变量的 jQuery 除法
【发布时间】:2014-04-07 11:14:33
【问题描述】:

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

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

感谢您的帮助!

【问题讨论】:

  • $(".container").width(x / y);
  • x / y @OP 似乎返回一个负值。

标签: jquery css width divide


【解决方案1】:
$(".container").css("width", (x / y));

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-05
    相关资源
    最近更新 更多