Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

clonealldivswithsameclassNOTonclick

I want to get the input value of all divs with class .hlighted and append them to another div. but with the code I tried I get the value appearing twice (or actually the X times there's a .hlighted label. How do I get this to appear only once?

HTML:

<div class="checkbox">
  <label class="hlighted" for="input1">
<input name="input1" value="input1">
label 1</label>
</div>
<div class="checkbox">
  <label for="input2">
<input name="input2" value="input2">
label 1</label>
</div>
<div class="checkbox">
  <label class="hlighted" for="input3">
<input name="input3" value="input3">
label 1</label>
</div>
<div class="breadstring">
</div>

JQUERY:

$(".checkbox .hlighted").each(function() {
  var knowncopy = $(this).find("input").val();
  $(".breadstring").append(knowncopy);
});

Comments