Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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/7/python-2.7/5.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_Css_Background - Fatal编程技术网

使用jquery更改复杂背景

使用jquery更改复杂背景,jquery,css,background,Jquery,Css,Background,我想更改一个文件的背景色 使用jquery的元素来自: background: transparent linear-gradient(#C0B 45%, #C0B) 进入: 我试图用.removeAttr()删除背景属性, 但是什么都不管用。试试看 $(this.css('background-color','red')您可以像下面这样做 $('#element_id').css('background', 'none'); // remove background $('#element

我想更改一个文件的背景色 使用jquery的元素来自:

background: transparent linear-gradient(#C0B 45%, #C0B) 
进入:

我试图用.removeAttr()删除背景属性, 但是什么都不管用。

试试看
$(this.css('background-color','red')

您可以像下面这样做

$('#element_id').css('background', 'none'); // remove background
$('#element_id').css('background-color', '#000'); // set background color
$('#element_id').css({'background':'none', 'background-color': '#000'});
您可以像下面这样组合两行

$('#element_id').css('background', 'none'); // remove background
$('#element_id').css('background-color', '#000'); // set background color
$('#element_id').css({'background':'none', 'background-color': '#000'});

我找到了一条路。你必须这样做:

$(this).css("background","none");

之后,您可以添加自己的背景属性。

不,我以前试过。它不起作用。我以为您使用了内联
css
。无论如何,我已经更新了我的答案@thebiz