触发器隐藏按钮不起作用
Trigger hidden Button doesnt work
我正在尝试触发一个隐藏按钮。不幸的是,该事件不起作用。这是代码:
<div class="dyn-inp-group">
<div class="dyn-inps">
<div class="form-group form-group-options col-xs-12 dyn-inp">
<div class="col-md-6" style="padding: 0 10px 0 0;">
<input class="form-control" class="customerfirstName" name="customer[firstName][]" type="text" placeholder="First name" required="required">
</div>
<div class="entry input-group col-md-6" style="margin: 0;">
<input class="form-control" name="customer[lastName][]" type="text" placeholder="Last name" required="required">
<span class="input-group-btn hidden">
<button id="remove" class="btn btn-info btn-remove" type="button">
<span class="glyphicon glyphicon-minus"></span>
</button>
</span>
</div>
</div>
</div>
<div class="form-group form-group-options col-xs-12 dyn-btn">
<div class="input-group col-xs-12">
<button id="countInput" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-plus"></span> Add more
</button>
</div>
</div>
</div>
当你点击"添加按钮"时,我正在计算所有输入。
var customerCount= 1 ;
$( "#countInput" ).click(function() {
var e = document.getElementsByTagName('input');
var i ;
var s = 1 ;
for(i=0; i < e.length; i++) {
if(e[i].type== "text" && e[i].name=="customer[firstName][]" ) { s++ ; }}
customerCount=s;
});
我还有一个删除按钮。删除按钮不起作用。当我点击删除按钮时,我想再次对输入字段进行计数。
$( "#countInput" ).click(function() { This does not work
有什么想法吗?
我看不出有任何问题。两个按钮的点击都很好
$( "#countInput" ).click(function()
$( "#remove" ).click(function()
请在此处查看:https://jsfiddle.net/ucnh4z4q/1/
由于您已经在使用JQuery,您可以使用.ech(),而不是将纯js与JQuery混合,定义许多无用的变量
var customerCount= 1 ;
$('#countInput').click(function() {
$('input').each(function(item) {
var newCustomer;
if($(this).attr('name') === 'customer[firstName][]')
customerCount+=1;
});
console.log(customerCount);
});
$('#remove').click(function() {
customerCount-=1;
console.log(customerCount);
});
这里是一个正在工作的jsfiddle
相关文章:
- 点击按钮输入不起作用
- Js.erb VS按钮标记-不'不起作用.为什么?
- 按钮字段确认点击不'不起作用
- JQuery示例不起作用-“;对象没有't支持属性或方法'按钮'&”;
- ng disabled在chrome中不起作用.按钮在角度上未禁用
- JS动态添加字段-删除按钮不起作用
- 角度无线电按钮ng模型不起作用
- 当我通过.aspx.cs创建按钮时,它不起作用
- 一键启动按钮不起作用
- 带有向下钻取的 Amchart 图表工作正常,但“后退”按钮不起作用
- 为什么不'这个HTML按钮不起作用
- 使用javascript后,提交按钮不起作用
- 表单中的提交按钮在 PHP 打印中不起作用
- 镀铬延长件内部的聚合物纸按钮不起作用
- 我的提交按钮不起作用
- 搜索按钮谷歌地图在我的vf页面上不起作用
- AngularJs:多次点击同一个按钮不起作用
- 我尝试将引导下拉按钮添加到 但下拉菜单不起作用.我该怎么做
- visualforce页面javascript按钮点击不起作用
- 单击功能不起作用按钮