function add() {
var new_chq_no = parseInt($('#total_chq').val()) + 1;
var new_input = "<input type='text' id='new_" + new_chq_no + "'>";
$('#new_chq').html(new_input);
}
function remove() {
var last_chq_no = $('#total_chq').val();
if (last_chq_no > 1) {
$('#new_' + last_chq_no).append('');
$('#total_chq').val(last_chq_no - 1);
}
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text">
<button onclick="add()">Add</button>
<button onclick="remove()">remove</button>
<div id="new_chq"></div>
<input type="hidden" value="1" id="total_chq">Run Code Online (Sandbox Code Playgroud)
它一次添加输入字段,第二次单击它不添加任何内容并且删除按钮不起作用
我有一个table,我正在添加新行javascript并event在新行上添加一个,但它不起作用。
这是我的代码:
function moreitem() {
document.getElementById('tottr').value = parseInt(document.getElementById('tottr').value) + 1;
ain = document.getElementById('tottr').value;
$('#mytable tbody tr:last')
.after("<tr><td><select name='pid[]' id='' class='form-control' onchange='getstock(this.value,'st" + ain + "','pc" + ain + "')'><option value=''>Select Product</option><option value='1'>Drink</option></select></td><td><input type='text' id='st" + ain + "' placeholder='Available Stock' class='form-control'></td><td><input type='text' id='qty" + ain + "' onchange='gettot(this.value,ain)' name='qty[]' placeholder='Quantity' class='form-control'></td><td><input type='text' id='pc" + ain + "' name='pprice[]' placeholder='Per Piece Price' class='form-control'></td><td><input type='text' name='tprice[]' placeholder='Total Price' id='tp" + ain + "' class='form-control'></td></tr>");
}
function …Run Code Online (Sandbox Code Playgroud)function chk() {
var a = $('#chkAll').prop('checked');
if (a == true)
$('.hobbie').attr('checked', 'checked');
else
$('.hobbie').removeAttr('checked');
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Select All <input onclick="chk()" type="checkbox" id="chkAll">
<br>
<input type="checkbox" class="hobbie">
<input type="checkbox" class="hobbie">
<input type="checkbox" class="hobbie">
<input type="checkbox" class="hobbie">Run Code Online (Sandbox Code Playgroud)
如果我点击选择所有复选框,则选择所有复选框,如果我再次点击它取消选中所有复选框,但在此之后它不工作,直到我刷新页面.
我正在学习 reactjs。我安装我的反应应用程序
create-react-app first
Run Code Online (Sandbox Code Playgroud)
但我想知道是否有任何手动安装反应应用程序的方法