Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript&;jquery语法_Javascript_Jquery_Syntax - Fatal编程技术网

Javascript&;jquery语法

Javascript&;jquery语法,javascript,jquery,syntax,Javascript,Jquery,Syntax,我不知道如何搜索这个,所以我在这里问 我正试图弄明白这段代码是如何工作的: if ($("#main .oc .dc .image").removeAttr("style"), 1120 > wW && wW > 920) $("#main .oc .dc .image").css({ width: Math.round(.3 * wW) + "px", left: "calc(50% - " + Math.round(.3 *

我不知道如何搜索这个,所以我在这里问

我正试图弄明白这段代码是如何工作的:

if ($("#main .oc .dc .image").removeAttr("style"), 1120 > wW && wW > 920)
    $("#main .oc .dc .image").css({
        width: Math.round(.3 * wW) + "px",
        left: "calc(50% - " + Math.round(.3 * wW / 4) + "px)"
    });
我的问题是——

在本语句中,
.removeAttr(“style”)
1120>wW
之间的逗号起什么作用

以及行动是如何执行的-

$("#main .oc .dc .image").css(
图前括号和css属性缺少引号-

{width:Math.round(.3*wW)+"px",left:"calc(50% - "+Math.round(.3*wW/4)+"px)"}

让我困惑。

谢谢你的问题,m aksem…
谢谢你的解释,@vlaz

我学到了一些新东西
我制作了一个测试片段来完成以下内容:

var wW=1000;
$(“#test1”)。在(“单击”,函数()上){
if($(“#main.oc.dc.image”).removeAttr(“样式”),1120>wW&&wW>920
$(“#main.oc.dc.image”).css({
宽度:数学圆(.3*wW)+“px”,
左:“计算(50%-”+数学四舍五入(.3*wW/4)+“px)”
});
});
$(“#test2”)。在(“单击”,函数()上){
如果(1120>wW&&wW>920)
$(“#main.oc.dc.image”).css({
宽度:数学圆(.3*wW)+“px”,
左:“计算(50%-”+数学四舍五入(.3*wW/4)+“px)”
});
});
$(“#test3”)。在(“单击”,函数()上){
if(false,1120>wW&&wW>920)
$(“#main.oc.dc.image”).css({
宽度:数学圆(.3*wW)+“px”,
左:“计算(50%-”+数学四舍五入(.3*wW/4)+“px)”
});
});
.image{
边框:1px纯黑;
宽度:50%;
位置:绝对位置;
左:20px;
}

主要的
oc
直流电
形象






if
statement@adeneotrue-当提供逗号分隔的条件时,仅检查最后一个条件:。我仍然认为这是坏习惯though@RoryMcCrossan-最肯定的是,没有理由以这种方式删除该属性,它可以放在
条件之前自己的行上。如果
条件,某人只是“聪明”。有人找到了写一些“聪明”的方法仅用于降低可读性的代码。@LouySpatriceBesette对其进行评估。然而,它的结果被扔掉了。因此,它将删除属性,但是,返回值并不重要,因为将返回布尔计算值。