Javascript 如何对每个克隆表单使用相同的函数
我有一个可以克隆到新表单的表单,我有一个可以在每个表单中克隆的表 这是我的表格Javascript 如何对每个克隆表单使用相同的函数,javascript,jquery,forms,Javascript,Jquery,Forms,我有一个可以克隆到新表单的表单,我有一个可以在每个表单中克隆的表 这是我的表格 <div class="box box-body form_pengeluaran"> <section class="content-header"> <h3>Pengeluaran</h3> <button type="button" class="btn btn-success tambah_form_pengeluaran">Ta
<div class="box box-body form_pengeluaran">
<section class="content-header">
<h3>Pengeluaran</h3>
<button type="button" class="btn btn-success tambah_form_pengeluaran">Tambah Pengeluaran</button>
</section>
<br>
<div class="col-md-12">
<div class="form-group">
<label>Tanggal Pengeluaran</label>
<input type="text" name="tgl_pengeluaran" id="tgl_pengeluaran" class="form-control" required>
</div>
<div class="form-group">
<label>Nama Toko</label>
<input type="text" name="nama_toko" id="nama_toko" class="form-control" required>
</div>
<div class="form-group">
<label>Metode Pembayaran</label>
<select class="form-control" name="metode_pembayaran" id="metode_pembayaran" style="width: 100%;" required>
<option selected disabled>-- Pilih Metode Pembayaran --</option>
<option>Debit</option>
<option>Kredit</option>
</select>
</div>
<br>
<div class="form-group table-responsive table_barang">
<table class="table table-bordered">
<thead>
<tr>
<th>Jumlah Barang</th>
<th>Nama Barang</th>
<th>Harga Barang</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" name="jlh_barang" id="jlh_barang" class="form-control"></td>
<td><input type="text" name="nama_barang" id="nama_barang" class="form-control"></td>
<td><input type="text" name="jlh_harga" id="jlh_harga" class="form-control"></td>
<td><button type="button" class="btn btn-success glyphicon glyphicon-plus tambah_barang"></button></td>
</tr>
</tbody>
</table>
</div>
<div class="form-group total_harga">
<table class="table">
<thead>
<tr>
<th>Total Harga Barang</th>
<td><input type="text" name="jlh_semua_harga" id="jlh_semua_harga" class="form-control" readonly></td>
</tr>
</thead>
</table>
</div>
</div>
<div class="col-md-12">
<hr>
</div>
</div>
这是你可以像我在下面贴的那样简单地写的。代码是自我记录的
html
<table id="table1">
<tr>
<td><input type=text value=""></td>
<td><button data-row-action="add">add</button></td>
</tr>
</table>
<table id="table2">
<tr>
<td><input type=text value=""></td>
<td><button data-row-action="add">add</button></td>
</tr>
</table>
并在任何表上调用插件
$('#table1').myTablePlugin();
$('#table2').myTablePlugin();
...
你可以像我在下面贴的那样简单地写。代码是自我记录的
html
<table id="table1">
<tr>
<td><input type=text value=""></td>
<td><button data-row-action="add">add</button></td>
</tr>
</table>
<table id="table2">
<tr>
<td><input type=text value=""></td>
<td><button data-row-action="add">add</button></td>
</tr>
</table>
并在任何表上调用插件
$('#table1').myTablePlugin();
$('#table2').myTablePlugin();
...
制作自己的jquery插件,克隆后在其上绑定该函数。因此,在没有创建插件的情况下,没有其他方法可以绑定函数??创建自己的jquery插件,并在克隆后在其上绑定该函数。因此,没有其他方法可以在不创建插件的情况下绑定函数??