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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -