I tried with this code but didn't work with me:
var data = document.querySelector;
$( document ) .querySelector('.class2').textContent() {
$('.class1').val('.class2');
});
The whole idea is that I want to get data from class2 and replace them in class1 and collect them with the Form inputs.
Thank you!
$()with javascript.querySelector. And do you wantdata-? or the value? or the text? In this case creating including HTML may help, along with expected input/output values. See minimal reproducible example.$(".class1").val($(".class2").text())but without HTML/expected values, hard to tell.{% for line_item in cart.items %} <input type="hidden" name="entry.2105509418" id="class1" value=""> <span class="class2">{{line_item.product.title}}, {{line_item.quantity}} - </span> {% endfor %}, I want to det data from SPAN class2 and collect them in value of input class1 , any recommendations to make it works even with Javascript or jQuery? thanks in advanceid="class1"/class="class2"- that's pretty confusing to use "class1" in anid=. You can edit your question and add that info rather than in a comment. Also if you have a for loop, then don't useid=inside it because IDs must be unique with the document. Give your hidden input a class.cart.items?