Jquery 在单击输入按钮后显示下一个按钮
Jquery to display next button once a input button is clicked
一旦用户单击输入,我就会尝试显示"下一步按钮",因此他们只有在做出选择后才能获得下一个按钮,我正在为这个项目使用引导程序。
小提琴是我迄今为止所拥有的。
任何帮助表示赞赏
http://jsfiddle.net/RS41/dvgxga2j/1/
<div class="btn-group-vertical" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio" name="options" id="option2" name="1" class="a"> <span class="label num" style="font-size:18px; margin-bottom:15px; border-radius:0px;">A</span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</label>
<label class="btn btn-default">
<input type="radio" name="options" id="option2" name="1" class="b"> <span class="label num" style="font-size:18px;margin-bottom:15px;border-radius:0px;">B</span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</label>
<label class="btn btn-default">
<input type="radio" name="options" id="option3" name="1" class="c"> <span class="label num" style="font-size:18px;margin-bottom:15px;border-radius:0px;">C</span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</label>
<label class="btn btn-default">
<input type="radio" name="options" id="option3" name="1" class="d"> <span class="label num" style="font-size:18px;margin-bottom:15px;border-radius:0px;">D</span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</label>
</div>
<br / >
<br / >
<div align="left">
<button class="btn btn2 btn-default" name="next">Next</button>
</div>
更新。。
嗨,按钮的全部意义在于移动到下一个屏幕,我已经实现了上面的代码,但是当我转到下一个屏幕时,下一个按钮已经出现,我本以为这个解决方案适用于所有屏幕。 我的小提琴很 http://jsfiddle.net/RS41/dvgxga2j/9/
注意:您在不同的元素上重复使用相同的ID(
option2
和option3
),这是错误的。
通过简单的方式,您可以使用jQuery执行此操作:
禁用/启用
$(document).ready(function () {
$("label input").click(function () {
$(".next").prop("disabled", false);
});
});
* {font-family: 'Segoe UI', Tahoma; margin: 0; padding: 0; list-style: none;}
input {vertical-align: middle;}
input[type=button] {padding: 2px 5px; margin: 5px 0;}
ul li {padding: 5px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<ul>
<li><label><input type="radio" name="one" /> Item 1</label></li>
<li><label><input type="radio" name="one" /> Item 2</label></li>
<li><label><input type="radio" name="one" /> Item 3</label></li>
<li><label><input type="radio" name="one" /> Item 4</label></li>
</ul>
<input type="button" class="next" value="Next" disabled="disabled" />
隐藏/显示
$(document).ready(function () {
$("label input").click(function () {
$(".next").removeClass("hidden");
});
});
* {font-family: 'Segoe UI', Tahoma; margin: 0; padding: 0; list-style: none;}
input {vertical-align: middle;}
ul li {padding: 5px;}
input[type=button] {padding: 2px 5px; margin: 5px 0;}
.hidden {display: none;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<ul>
<li><label><input type="radio" name="one" /> Item 1</label></li>
<li><label><input type="radio" name="one" /> Item 2</label></li>
<li><label><input type="radio" name="one" /> Item 3</label></li>
<li><label><input type="radio" name="one" /> Item 4</label></li>
</ul>
<input type="button" class="next hidden" value="Next" />
给按钮一个类:
<button class="btn btn2 btn-default myButton" name="next">Next</button>
使用 JS 隐藏按钮(这样对于关闭 JS 的人来说仍然可见)或 CSS:
$(".myButton").hide();
将事件侦听器附加到单选按钮,以便在单击按钮时更改按钮的显示属性:
$("input:radio").on("click", function(){
$(".myButton").show();
});
演示
这是您想要的解决方案:
$('[name="next"]').addClass('disabled');
$('[name="options"]').on('change',function(e){
e.preventDefault();
$('[name="next"]').toggleClass('disabled', !$('[name="options"]:checked').length);
})
小提琴
尝试像这样的东西
:
$(function() {
$('#nextbtn').hide();
$('input:radio').change(
function() {
$('#nextbtn').show();
}
);
});
<div class="btn-group-vertical" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio" name="options" id="option1" name="1" class="a" /> <span class="label num" style="font-size:18px; margin-bottom:15px; border-radius:0px;">A</span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</label>
<label class="btn btn-default">
<input type="radio" name="options" id="option2" name="1" class="b" /> <span class="label num" style="font-size:18px;margin-bottom:15px;border-radius:0px;">B</span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</label>
<label class="btn btn-default">
<input type="radio" name="options" id="option3" name="1" class="c" /> <span class="label num" style="font-size:18px;margin-bottom:15px;border-radius:0px;">C</span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</label>
<label class="btn btn-default">
<input type="radio" name="options" id="option4" name="1" class="d" /> <span class="label num" style="font-size:18px;margin-bottom:15px;border-radius:0px;">D</span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</label>
</div>
<br />
<br />
<div align="left">
<button id="nextbtn" class="btn btn2 btn-default" name="next" style>Next</button>
</div>
我刚刚从您的单选按钮中删除了一些不必要的属性(如 id、第二个名称和类),添加到 Next 按钮类中,这使得它在默认情况下不可见,并使用简单的 jQuery 操作我试图找到单选按钮中值的第一个变化。
jQuery 代码应如下所示:
$(function(){
$("input[type=radio]").change(function() {
$("#next_button").removeClass("hidden");
});
});
每次有人点击任何单选按钮时都会触发此命令。当它发生时,jQuery会删除"隐藏"类,使其可见。
隐藏的类应如下所示:
.hidden { display: none; }
这就是您所需要的。
看看这个: http://jsfiddle.net/dvgxga2j/6/
相关文章:
- 禁用旋转木马中的下一个按钮和上一个按钮
- 简单的垂直上一个和下一个按钮代码点击上下移动jQuery
- 按下一个HTML按钮,该按钮使用一个功能在同一个新窗口中打开URL
- 在单击下一个按钮之前,在JavaScript代码中添加5秒的延迟
- 正如我所能做的引导提醒,按下一个按钮可以更改语言
- JavaScript幻灯片显示,每个幻灯片的下一个按钮都有不同的位置
- 当我单击下一个或上一个按钮时,datatable显示旧值
- 一个具有两个图像按钮的表单在只能按下一个按钮的情况下发送两个按钮值
- 单击按钮进入下一个选项卡,而不是单击选项卡
- 为缩略图库和较大图像库添加下一个和上一个按钮
- 当滑块只有一个图像时,如何禁用下一个/上一个按钮
- 图像缩略图库中的“下一个”和“上一个”按钮中的“问题”
- 单击按钮时如何聚焦下一个文本字段
- 如何在猫头鹰旋转木马中滑动所有可见项目,而不是使用上一个/下一个按钮
- 一页主题搜索/用下一个按钮突出显示文本
- 如何为滑块的分页按钮创建简单的下一个和上一个触发器按钮
- jQuery UI 选项卡 - 将参数设置为下一个/上一个按钮单击
- 将下一个和上一个按钮添加到我的图像滑块
- JQuery,引导导航 - 如何添加上一个/下一个按钮
- 如何在cycle2.js中悬停img时同时显示上一个/下一个按钮