Dev Dev - 1 year ago 93
jQuery Question

Add class to div

How to add class to div while creating dynamic input.

div.class = "form-group";

Not working for me. which is commented in bellow code.

<script type="text/javascript">
function dynInput(cbox) {
if (cbox.checked) {
var input = document.createElement("input");
input.type = "text";
var div = document.createElement("div"); = cbox.value;
//div.class = "form-group";
div.innerHTML = "<label>Cost Per Test For " + cbox.value + "</label>";
} else {

Answer Source

Need to change to this:

  div.className = "form-group";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download