jquery - Add text to series of labels -
i have list of fields descriptions inside label tags. want add text "your" before each label.
so far have
<div id="field1"> <label> first label </label> </div> <div id="field2"> <label> second label </label> </div> <div id="field3"> <label> third label </label> </div> <div id="field4"> <label> fourth label </label> </div>
var label = $("label"); $("label").html("your"+ label.text);
https://jsfiddle.net/smftmdf1/1/
any method achieve without using classes or ids?
you need use jquery function each desired result.
var label = $("label"); $("label").each(function () { $(this).html("your" + $(this).text()) });
solution: https://jsfiddle.net/7g7ycqnu/
Comments
Post a Comment