Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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
这个jQuery语法在做什么?_Jquery - Fatal编程技术网

这个jQuery语法在做什么?

这个jQuery语法在做什么?,jquery,Jquery,我不理解.width和.parent()的。 谢谢。它将图像的宽度设置为其父对象的父对象的宽度(以及其他CSS设置)。请参阅和。您是否阅读了jQuery网站上关于这些方法的文档? $(".topLevelCategoryContainer img").width($(this).parent().parent().width()).css({ "text-align": "center", "border": "none", "margin-left": "0" }); // this get

我不理解.width和.parent()的。
谢谢。

它将图像的宽度设置为其父对象的父对象的宽度(以及其他CSS设置)。请参阅和。您是否阅读了jQuery网站上关于这些方法的文档?
$(".topLevelCategoryContainer img").width($(this).parent().parent().width()).css({ "text-align": "center", "border": "none", "margin-left": "0" });
// this gets images within the .topLevelCategoryContainer element
$(".topLevelCategoryContainer img")
    // this sets the width of the image
    .width(
        // this gets the value to set the width to, in this case
        // to the same width as the images parents parent
        $(this).parent().parent().width()
    )
    //this sets CSS on the image
    .css({ 
       "text-align": "center", 
       "border": "none", 
       "margin-left": "0" 
    });