RSM
RSM

Reputation: 15118

Create submit button in table

I am using Jquery to go through an array and make a new table row for each element in the array.
At the end of each row I want a submit button with the value Add To Cart.

Here's some relevant code:

var addToCartCell = document.createElement('td');
$(tableRow).append(addToCartCell);

To add the submit button, so far I have tried:

$("<input type='submit' value='Add To Cart'").appendTo(addToCartCell);

And,

$(addToCartCell).append("<input type='submit' value='Add To Cart'");

But to no avail

Upvotes: 0

Views: 1026

Answers (2)

Andreas
Andreas

Reputation: 21911

You're missing the closing />

$("<input type='submit' value='Add To Cart' />").appendTo(addToCartCell);

Upvotes: 1

Darragh Enright
Darragh Enright

Reputation: 14136

You're missing a closing angle bracket in each case. Try:

$(addToCartCell).append('<input type="submit" value="Add To Cart">');

Upvotes: 1

Related Questions