I am using below mentioned code for creating checkboxes and labels dynamically. But label and checkboxes are not aligning in same line. Can anyone guide what is wrong in below code?
dojo.require("dijit.form.CheckBox");
dojo.ready(function(){
var widgetNode = dojo.doc.createElement("DIV");
chk = dojo.create("input", {id:"cbox", type:"checkbox"}, widgetNode);
lbl = dojo.create("label", {innerHTML:"Check me", "for":"cbox"}, widgetNode);
dojo.style(lbl, "marginLeft", ".5em");
var cbWidget = new dijit.form.CheckBox({}, chk);
cbWidget.startup();
cbWidget.domNode.appendChild(lbl);
dojo.place(cbWidget.domNode, "container");
});
I usually put the checkbox inside the label instead of using the for="zzz"
syntax. Just is a bit easier. I think the easiest way to get what you want is to include a dijit theme . Including one of the themes like Claro will automatically have the styles to put the checkbox inline. Example here: http://jsbin.com/fusijoc/1/edit?html,js,output
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.