【发布时间】:2016-10-26 11:56:02
【问题描述】:
您好,我正在使用无线电输入制作幻灯片,并设计了“上一个”和“下一个”按钮来移动幻灯片。但是,我还希望这些按钮也可以检查下一个输入。当前幻灯片移动,但未检查下一个输入。我在这里查看了这个解决方案: Select next/prev radio button with external button 并试图实现它,但我无法让它工作。这是我的代码:
<form action="" method="post">
<ul class="form-ul" style="position: relative; width: 176px; height: 107px;">
<li style="position: absolute; top: 0px; left: 0px; display: block; z-index: 5; opacity: 1; width: 82px; height: 43px;">
<label>
<input type="radio" name="term_id" value="59" checked="checked">
</label>
</li>
<li style="position: absolute; top: 0px; left: 0px; display: none; z-index: 4; opacity: 0; width: 82px; height: 62px;">
<label>
<input type="radio" name="term_id" value="61">
</label>
</li>
</ul>
<div id="prev" style="float:left;">PREV</div>
<div id="next" style="float:right;">NEXT</div>
</form>
JavaScript:
$(document).ready(function(){
$('#prev').click(function(){
$('.form-ul').find('li:has(input:checked)').prev().children('input').prop("checked", true);
});
$('#next').click(function(){
$('.form-ul').find('li:has(input:checked)').next().children('input').prop("checked", true);
});
});
【问题讨论】:
标签: javascript jquery button input radio