Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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
使用next()删除反向图像;和prev();在jqueryfrom菜单中_Jquery - Fatal编程技术网

使用next()删除反向图像;和prev();在jqueryfrom菜单中

使用next()删除反向图像;和prev();在jqueryfrom菜单中,jquery,Jquery,我正在尝试从a.current前后的中删除背景图像 因此,在下面的例子中,“草药”链接不会有一个,也不会有“费用” 任何帮助都将不胜感激 首先,我认为jQuery对象上没有“parent”属性,但有函数“parent()”。此外,您需要从“a”中删除背景,而不是从“li”中删除背景,因此应该是: $('li.current a').parent().prev().children('a').css('background', 'none'); 您不应该使用parent()。从上一版本的文档中

我正在尝试从
a.current前后的
中删除背景图像 因此,在下面的例子中,“草药”链接不会有一个,也不会有“费用”


任何帮助都将不胜感激

首先,我认为jQuery对象上没有“parent”属性,但有函数“parent()”。此外,您需要从“a”中删除背景,而不是从“li”中删除背景,因此应该是:

 $('li.current a').parent().prev().children('a').css('background', 'none');

您不应该使用
parent()
。从上一版本的文档中:

获取匹配元素集中每个元素的前一个同级,可选地通过选择器进行筛选

所以,它应该是这样的:

$('li.current a').prev().css('background', 'none');
$('li.current a').next().css('background', 'none');

您正在将
  • 定位在当前的
    之前和之后,但指定了错误的属性。尝试使用
    backgroundImage
    而不是
    background
    来删除背景图像。

    parent
    是一种方法,因此您需要编写
    parent()
    ,如果背景位于
  • 上,则此操作应该有效。
    注意:窗台打字错误!谢谢你指出。就像我在回答中写的,这里不需要父母()和孩子。只需
    prev()
    next()
    。如果没有“children()”,您将选择下一个/上一个“li”元素,而不是“a”。我的印象是,作者需要删除“a”中的背景。
     $('li.current a').parent().prev().children('a').css('background', 'none');
    
    $('li.current a').prev().css('background', 'none');
    $('li.current a').next().css('background', 'none');