Adding span or div tags to checkbox and label
I've created a checkbox list in .net, but as part of a responsive design I need to keep the checkbox and the label on the same line. I thought that this would be a matter of inserting a span or div tag before the checkbox and after the label, and then I could add a nowrap class to keep them on the same line. At first I thought that .before and .after were what I needed, and these work fine if you add some random text, but not with html tags. If I add the span tag before the element, jQuery closes it. If I add a closing tag after an element it doesn't display at all.
- $("#accb input").before("<span>");
in desperation I tried to parse it as HTML (probably a complete misuse of the tag).
- $("#accb input").before($.parseHTML("<" + "span" + ">"));
I tried .add to combine both elements and wrap the div around them but I got separate tags for each element.
- $cb = $("#accb input");
$lb = $("#accb label");
$nb = $cb.add($lb);
$nb.wrap("<div class='abc'></div>");
Perhaps I'm going about this the wrong way, any help would be greatly appreciated.