0

I currently create a new table row with:

const billingNewRow = billingTable.insertRow(firstLineNum + billingNewRowNum - 2);
const boldIt = billingNewRowNum > 2 ? true : false
const newHTML = po.billingNewRowHTML(billingNewRowText, billingNewRowNum, boldIt, homeBillingLinked());
p(newHTML); // <b>Street3</b>&nbsp;<input type=text id=billing-street-3 disabled>
billingNewRow.insertCell(0).innerHTML = newHTML;    //  <-- this works

if I try to use jquery and change that to

billingNewRow.insertCell(0).html(newHTML);

I get

billingNewRow.insertCell(...).html is not a function

Do I have to re-find the element in order to set the HTML ?
Is there another way ?

1
  • You can either convert the result of billingNewRow.insertCell(0) to a jQuery object using $(billingNewRow.insertCell(0)).html(newHTML), because you have too many CPU cycles on your hands, or just keep using innerHTML. Commented Mar 25, 2020 at 20:49

1 Answer 1

1

billingNewRow.insertCell(0) returns a DOM element, not a jQuery object. You need to use $() to convert it.

$(billingNewRow.insertCell(0)).html(newHTML)

But mixing DOM methods and jQuery like this is pretty strange. Why do you need to use .html() when you can just assign to .innerHTML?

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.