I have this code that I need to insert/replace with a surround
<div class="formBody"><input type="radio" id="Sex0" value="Male" name="form[Sex]"><label for="Sex0">Male</label><input type="radio" id="Sex1" value="Female" name="form[Sex]"><label for="Sex1">Female</label><span class="formValidation"><span class="formNoError" id="component1956">Male/Female</span></span></div>
I need to add this following surrounding <div class="ck-button">
code using jQuery.
<div class="formBody"><div csass="ck-button"><input type="radio" id="Sex0" value="Male" name="form[Sex]"><label for="Sex0">Male</label></div><div class="ck-button"><input type="radio" id="Sex1" value="Female" name="form[Sex]"><label for="Sex1">Female</label></div><span class="formValidation"><span class="formNoError" id="component1956">Male/Female</span></span></div>
I’ve tried using ‘replaceWith’ but not having any luck as the code I’m using is literal. For example:
jQuery( '<input type=\"radio\" id=\"Sex0\" value=\"Male\" name=\"form[Sex]\"><label for=\"Sex0\">Male</label>' ).replaceWith( '<div csass=\"ck-button\"><input type=\"radio\" id=\"Sex0\" value=\"Male\" name=\"form[Sex]\"><label for=\"Sex0\">Male</label></div><div class=\"ck-button\"><input type=\"radio\" id=\"Sex1\" value=\"Female\" name=\"form[Sex]\"><label for=\"Sex1\">Female</label></div>' );
So where am I going wrong and how do I fix it?