我有我的滑动滑块,想知道如何通过next和prev按钮更改单选按钮,我不擅长js或jquery,如果您可以帮助我我会很乐意:(我如何通过下一个prev更改单选按钮
<section class="center slider">
<div class="type">
<label><input type="radio" name="type" value="1" checked /><img src="./images/1.png"></label>
</div>
<div class="type">
<label><input type="radio" name="type" value="2" /><img src="./images/2.png"></label>
</div>
<div class="type">
<label><input type="radio" name="type" value="3" /><img src="./images/3.png"></label>
</div>
<div class="type">
<label><input type="radio" name="type" value="4" /><img src="./images/4.png"></label>
</div>
<div class="type">
<label><input type="radio" name="type" value="5" /><img src="./images/5.png"></label>
</div>
<div class="type">
<label> <input type="radio" name="type" value="6"/><img src="./images/6.png"></label>
</div>
<div class="type">
<label><input type="radio" name="type" value="7" /><img src="./images/7.png"></label>
</div>
</section>
<button type="button" data-role="none" class="slick-prev" aria-label="Previous" tabindex="0" role="button">Previous</button>
<button type="button" data-role="none" class="slick-next" aria-label="Next" tabindex="0" role="button">Next</button>
我试图用一些JS更多:
<button type="button" onclick="dayNavigation('prev');"data-role="none" class="slick-next" aria-label="Next" tabindex="0" role="button">Next</button>
<button type="button" onclick="dayNavigation('next');" data-role="none" class="slick-prev" aria-label="Previous" tabindex="0" role="button">Previous</button>
dayNavigation = function (direction) {
var all = $('.slider input:radio');
var current = $('.slider input:radio:checked');
var index;
if (direction == 'slick-prev') {
index = all.index(current) - 1;
} else {
index = all.index(current) + 1;
}
if(index >= all.size()) index = 0;
all.eq(index).click();
return false;
};
你尝试过这么远吗?你可能想看看[问] – user1859022
我刚刚编辑我尝试 – razvai
你可以请添加Css代码。并添加你在这个模型中使用的库 –