我是 jQuery 和 PHP 的新手,所以我知道我的编码充其量是非常粗糙的,但我需要帮助。
我的 PHP 编码:
<td style="width: 39px; height: 30px;">
<select id="choice" name="choice" class="ddl" style="width: 150px">
<?php foreach($xml->children() as $pizza){ ?>
<option value="<?php echo $pizza; ?>" selected=""><?php echo $pizza; ?></option>
<?php }?>
</select></td>
<td style="height: 30px; width: 32px;">
<input id="num" name="num" class="dd2" style="width: 46px"
type="number"></td>
<td style="height: 30px; width: 91px;">
<input TYPE = "button" id="addbt" Name = "addbt" VALUE = "Add Pizza" class="auto-style1"></td>
<td style="height: 30px">
<input TYPE = "button" id="removebt" Name = "removebt" VALUE = "Remove A Pizza" class="auto-style1"></td>
</tr>
<tr>
<td style="width: 131px; height: 30px;"> </td>
<td style="width: 39px; height: 30px;">
</td>
<td style="height: 30px; width: 32px;">
</td>
<td style="height: 30px" colspan="2">
</td>
</tr>
<tr>
<td style="width: 131px">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Submit Order"></td>
<td colspan="4"><input id="reset" type="button" value="Reset Order"></td>
</tr>
</table>
<p> </p>
</form>
jQuery编码是:
<script type="text/javascript">
$("#addbt").click(function () {
$('#choice').clone()
.attr('id', 'choice' + $('.ddl').length)
.attr('name', 'choice' + $('.ddl').length)
.insertAfter(".ddl:last");
$('#num').clone()
.attr('id', 'num' + $('.dd2').length)
.attr('name', 'num' + $('.dd2').length)
.insertAfter(".dd2:last");});
$("#removebt").click(function () {
$("#choice1").remove();
$("#num1").remove();
});
$('#reset').click(function() {
location.reload();});
</script>
如何影响克隆的布局?当我创建超过五个克隆时,它们的高度不再相等。