Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.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 如何检查li:contains metod中的两个参数_Javascript_Jquery_Css - Fatal编程技术网

Javascript 如何检查li:contains metod中的两个参数

Javascript 如何检查li:contains metod中的两个参数,javascript,jquery,css,Javascript,Jquery,Css,我用这个方法来改变css $("#AllProducts li:contains('" + Product + "')").css("background", "white"); 这很好,但现在我需要检查两个参数,当我检查css时,有些人会这样想 $("#AllProducts li:contains('" + Product + "')&&('" + iCategory + "') ").css("background", "white"); 但这不起作用。我无法检查是否包

我用这个方法来改变css

$("#AllProducts li:contains('" + Product + "')").css("background", "white");
这很好,但现在我需要检查两个参数,当我检查css时,有些人会这样想

$("#AllProducts li:contains('" + Product + "')&&('" + iCategory + "') ").css("background", "white");

但这不起作用。我无法检查是否包含产品,也无法检查iCategory是否需要将它们放在同一个对象中。

我想您正在寻找一些东西。简单回答,试试这个:

$("#AllProducts li:contains('" + Product + "'):contains('" + iCategory + "') ")
那么:

$("#AllProducts li:contains('" + Product + "'):contains('" + iCategory + "')").css("background", "white");
双硅酸盐