当我使用.before()
或.after()
this.vehicle = $('<input>');
this.vehicle.attr({
id: "invoiceItemVehicle",
name: "invoiceItemVehicle",
class: "invoiceItemControl"
});
this.vehicle.before('<label>Vehicle</label>');
this.vehicle.after('<br /><br />');
出于某种原因,
this.vehicle.append('<label>Vehicle</label>');
会将标签放在输入中,但在使用.before()
和.after()
时没有任何反应。我也没有收到任何错误消息。这是jquery输入处理的问题吗?
所需的输出是车辆: _ __ _ __ _ _ (双线换行)
答案 0 :(得分:0)
尝试使用jQuery wrap()函数。
用于测试的HTML:
<div class="test"></div>
和JS:
this.vehicle = $('<input>');
this.vehicle.attr({
id: "invoiceItemVehicle",
name: "invoiceItemVehicle",
class: "invoiceItemControl"
});
this.vehicle.wrap('<label>Vehicle: </label>');
$('.test').append(this.vehicle.parent());