How do I get the value from & lt; and & gt ;, which came there as a time-lapse?

  • 0
    <strong><a name="caloru" th:each="elem : ${food[0]}" th:text="${elem.calories}"></a></strong>

    How can I get the value from this line? It is necessary to further process it in JS, but I cannot get the value itself. An integer should come in th: text.
    JavaScript Natalie Barnett, Dec 31, 2019

  • 1 Answers
  • 0
    If I understood correctly, then something like this

    let food = [10];
    let elem = {
    calories: 555
    const html = `<strong><a name="caloru" th:each="elem : ${food[0]}" th:text="${elem.calories}">тег а</a></strong>`;

    document.body.insertAdjacentHTML('beforeend', html);

    const el = document.querySelector('[name="caloru"');
    const thEach = el.getAttribute('th:each');
    const thText = el.getAttribute('th:text');

    console.log(thEach, thText);

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!