jQuery AND选择器的逻辑与 [英] Logic AND for Jquery selector
本文介绍了jQuery AND选择器的逻辑与的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想设置为按值AND名称选中输入的复选框.
I want to set to checked a checkbox input by value AND name..
<input name="email" type="checkbox" value="1" tabindex="2">
我该怎么做?我需要两个条件都完成.
How can I do that? I need that both conditions are done.
这在&&
This fails on &&
$("input[name=email] && [value='+i+']").attr('checked', true);
此代码已放入for迭代中,"i"采用了一个数值. 预先感谢您的时间和帮助...
This code is into a for iteration and "i" is taking a numeric value. Thanks in advance for your time and help...
推荐答案
只需同时使用两个选择器:
Just use both selectors next to each other:
$("input[name=email][value=" + i + "]").prop('checked', true);
任何选择器之间没有空格的情况将应用于同一元素.
Any selectors that have no space between them are applied to the same element.
这篇关于jQuery AND选择器的逻辑与的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文