I have this function for building HTML.
CreateInputCheckboxActive: function (id, mainClass, checked, headerTxt, inputTxt) {
    var bootstrapClass = "col-sm-6 ";
    return (
     $("<div/>", { class: bootstrapClass + mainClass }).append(
         $("<label/>", { "text": headerTxt }),
         $("<input/>", {
            "id": mainClass,
            "class": mainClass,
            "type": "checkbox",
            "checked": checked
         }),
         $("<label/>", {
            "class": mainClass,
            "for": mainClass,
            "text": checked == true ? inputTxt[0] : inputTxt[1]
         })
         )
     );
}
How can I create the first label just if the parameter headerTxt has a value? I want to use this way of jquery.
 
    