0

I have a problem with create id or class on my table row. I use Firebase and read data to table in this way.

$("#table_body").append(
        "<tr>"+
            "<td>" + doc.data().id + "</td>"+
            "<td>" + doc.data().nazwa + "</td>"+
            "<td>" + doc.data().cena + "</td>"+
            "<td>" + doc.data().ilosc + "</td>"+
        "</tr>"
        );

How can I add className or Id to "tr" ?

2
  • To which element you wanna add id? Commented Jan 27, 2019 at 11:07
  • I need add id to tr Commented Jan 27, 2019 at 11:10

1 Answer 1

1

You should use template strings for this purpose here is your code with template strings

$("#table_body").append(
        `<tr id=${myIdVariable}>
            <td>${doc.data().id}</td>
            <td>${doc.data().nazwa}</td>
            <td>${doc.data().cena}</td>
            <td>${doc.data().ilosc}</td>
        </tr>`
        );

with in a template string you can insert you variable in string like this ${variableName}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.