[英]Checkbox before label text in jQuery
I have the following function: 我有以下功能:
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);
},
Now, this works, but it produces the following result: 现在,这可行,但它产生以下结果:
I want to add the checkbox before the label so it would look like [x] Document Files
. 我想在标签前添加复选框,使其看起来像
[x] Document Files
。 Is there a way to do this without using html()
? 有没有不使用
html()
?
或者你只能使用CSS:在<input>
元素上使用类似于float: left
的属性float: left
;或者在<label>
元素上使用float: right
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.