Reputation: 1664
I am attempting to change the form label below using Jquery but found that changing the HTML removed the form element inside the label. Can anyone show me how I can change the lable text without removing the form element. Thanks!
<label for="field_217-0">
<input id="field_217-0" type="radio" value="Yes" name="item_meta[217]"></input>
Yes
</label>
Lets say I want to change above to 'Yes Sir!'
So far all I have is:
jQuery(document).ready(function($){
$(document).ready(function() {
$("label[for='field_217-0']")
});
});
Upvotes: 0
Views: 51
Reputation: 10572
You can save the input and then replace the contents with the input and the new label:
var label = $("label[for='field_217-0']");
var input = label.find("input");
label.html(input).append("New Label");
...also you don't need the duplicate .ready()
layers.
Upvotes: 1