jQuery匹配多个属性

我有以下的标记,我想使All单选button被选中。

 <ul> <li><input type="radio" value="All" name="Foo"/>All</li> <li><input type="radio" value="New" name="Foo"/>New</li> <li><input type="radio" value="Removed" name="Foo"/>Removed</li> <li><input type="radio" value="Updated" name="Foo"/>Updated</li> </ul> 

我想通过属性进行匹配,但是我需要匹配2个属性, @name='Foo'@value='All'

像这样的东西:

 $("input[@name='Foo' @value='all']").attr('checked','checked'); 

有人可以展示如何做到这一点?

以下HTML文件显示了如何执行此操作:

 <html> <head> <script type="text/javascript" src="jquery-1.2.6.pack.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("a").click(function(event){ $("input[name='Foo'][value='All']").attr('checked','checked'); event.preventDefault(); }); }); </script> </head> <body> <ul> <li><input type="radio" value="All" name="Foo" />All</li> <li><input type="radio" value="New" name="Foo" />New</li> <li><input type="radio" value="Removed" name="Foo" />Removed</li> <li><input type="radio" value="Updated" name="Foo" />Updated</li> </ul> <a href="" >Click here</a> </body> </html> 

当你点击链接时,所需的单选button被选中。 重要的一行是设置checked属性的行。

我在类似这样的墙上打我的头,只是想指出,在jQuery 1.3中接受的答案中使用的语法是唯一的语法,将工作。 提问者对expression式使用@语法,在jQuery中根本不起作用。 希望这有助于下一个人通过谷歌= p来解决这个问题

要清楚,你必须使用

 jQuery('input[name=field1][val=checked]') 

并不是

 jQuery('input[@name=field1][@val=checked]')