2
标签文本之前
我有以下功能:复选框jQuery中
addCheckbox: function (name, parent, value, text) {
var div = jQuery("#" + parent);
var input = jQuery(document.createElement('input')).attr({
id: "cbid_" + value,
name: name,
value: value,
type: 'checkbox'
});
var label = jQuery("<label>").text(text);
input.appendTo(label);
div.append(label);
},
现在,这个工作,但它产生以下结果:
我想补充的复选框之前的标签,所以它看起来像[x] Document Files
。有没有办法做到这一点,而不使用html()
?
使用prepend http://api.jquery.com/prepend/ – Kasma 2013-03-12 10:45:09