jquery - 功能工作窗口调整大小

标签 jquery html

这是我的代码

var bodyWidth = ($(document).width()/2);
console.log(bodyWidth);
$('.freeshipping').css('right',bodyWidth);

它很好,但我想要这个功能主体调整大小和页面刷新。怎么办?

最佳答案

$(window).resize(function(){
    var bodyWidth = ($(document).width()/2);
    console.log(bodyWidth);
    $('.freeshipping').css('right',bodyWidth);
});

更新:调用函数一次:

$(window).resize((function(){
   var bodyWidth = ($(document).width()/2);
   console.log(bodyWidth);
   $('.freeshipping').css('right',bodyWidth);

   return arguments.callee;
})());​

关于jquery - 功能工作窗口调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10634817/

相关文章:

jquery - 我怎样才能让我的幻灯片显示在我的主页上?

javascript - 根据带有模式名称的 id 选择 anchor 标记

javascript - 单击功能在动态创建的元素 Jquery 上无法按预期工作

javascript - 在其外部单击关闭 DIV 弹出窗口

c# - DNN 6 jQuery 选项卡

html - 2 "style"内联 css img 标签?

jquery - 输入点击不起作用

jquery - 使 Bootstrap 下拉按钮级联

html - 为什么每当我添加 "overflow-y: scroll"时我的 div 都会向右移动?

javascript - 检索元素父索引