How do i can remove the "John Doo" text in this block and then add some html content?
<label><input type="radio" name="field-value-1359303" value="Joe Doe">Joe Doe</label>
My "solution"
$('input[value="Joe Doe"]')
.hide()
.parents('label')
????
.append('<div>my content</div>');
The end result should be as follows:
<label><input type="radio" name="field-value-1359303" value="Joe Doe"><div>my content</div></label>
2
Answers
You could use vanilla javascript (not jQuery)
NOTE: for this code to run as is you have to add id="lab" to the label element.
1st solution (innerHTML is not the best decision)
With this solution I assume you can have access to the label element.
2nd solution (you have to change the structure of your html)
Personally I would go with the second solution because innerHTML can lead to problems and I don’t think an additional span would create any issues.
You must declare a param to save the input, clear label body by html() before appending the input and div