Jquery 这个函数在javascript中做什么?

Jquery 这个函数在javascript中做什么?,jquery,Jquery,我正在尝试使用jQuery制作一个滑动转盘,下面是代码,我不知道这个函数到底做了什么 $w.bind('resize.example', function () { var nw = $w.width(); if (nw < 900) { nw = 900; } $c.width(nw * 3); $c.parent().width(nw); }).trigger('resize.example'); $w.bind('resi

我正在尝试使用jQuery制作一个滑动转盘,下面是代码,我不知道这个函数到底做了什么

$w.bind('resize.example', function () {
    var nw = $w.width();
    if (nw < 900) {
        nw = 900;
    }

    $c.width(nw * 3);
    $c.parent().width(nw);

}).trigger('resize.example');
$w.bind('resize.example',函数(){
var nw=$w.width();
如果(nw<900){
nw=900;
}
$c.宽度(西北*3);
$c.父项()宽度(nw);
}).trigger('resize.example');

我相信您使用的是低于jQuery v1.7的版本,因为您使用的是
bind()
,在1.7之后的版本中不推荐使用

$w.bind('resize.example',function(){

此行绑定
调整大小的事件。例如
$w
元素上的
resize.example
是自定义事件,我相信
$w
是用jQuery包装的
窗口
对象

触发器('resize.example')

这会触发事件调整大小。例如,这非常常见。这用于在页面加载上运行事件处理程序

var nw = $w.width();
if (nw < 900) {
    nw = 900;
}
这部分代码将
$c
的宽度设置为
nw
的3倍。 将名为“resize.example”的自定义事件绑定到$w元素
//Bind a  custom event named 'resize.example' to the $w element
$w.bind('resize.example', function () {

    //Store the $w width in a variable named 'nw'
    var nw = $w.width();

    if (nw < 900) {
        //If nw < 900 --> set the 'nw' var equal to 900
        nw = 900;
    }

    //Set the $c element width equal to 900*3=2700px
    //*** $c is not defined here..
    $c.width(nw * 3);

    //Set the parent of $c equal to 900px
    $c.parent().width(nw);

}).trigger('resize.example');  //Trigger the custom event to execute the function
$w.bind('resize.example',函数(){ //将$w宽度存储在名为“nw”的变量中 var nw=$w.width(); 如果(nw<900){ //如果nw<900-->将“nw”变量设置为900 nw=900; } //将$c元素宽度设置为900*3=2700px //***此处未定义$c。。 $c.宽度(西北*3); //将$c的父级设置为900px $c.父项()宽度(nw); }).trigger('resize.example')//触发自定义事件以执行函数
//Bind a  custom event named 'resize.example' to the $w element
$w.bind('resize.example', function () {

    //Store the $w width in a variable named 'nw'
    var nw = $w.width();

    if (nw < 900) {
        //If nw < 900 --> set the 'nw' var equal to 900
        nw = 900;
    }

    //Set the $c element width equal to 900*3=2700px
    //*** $c is not defined here..
    $c.width(nw * 3);

    //Set the parent of $c equal to 900px
    $c.parent().width(nw);

}).trigger('resize.example');  //Trigger the custom event to execute the function