我的问题很简单。我正在使用模板来做造型。模板处理表单输入的方式是将它们包装在 span 标签中。要选择单选按钮,您必须将跨度的类更改为“选中”。 在输入中使用 checked="checked"或 checked 无效。
例子:
<label class="radio">
<div class="radio" id="uniformed-undefined">
<span class="checked">
<input type="radio" name="grow" value="slash">
</span>
</div>
我如何定位 <span class="checked">
基于输入名称“grow”和值“slash”?
我已经研究过 .before() 但我不确定这是正确的答案。
最佳答案
jQuery multiple attribute selector
和 jQuery parent
$("input[name='grow'][value='slash']").parent("span");
关于javascript - 定位环绕 radio 输入的跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24420638/