Josh Woelfel
Josh Woelfel

Reputation: 1969

jquery showing table row upon click

I have a form within a table. I have 10 inputs within the form. Initially, i'm only showing the first 4 inputs. onClick of the "add more inputs" I want to show another input consecutively. At this time, this jQuery snippet isn't breaking anything else on the page, but it's just not showing the next line.

var inputNumber = 5;

$("#addMore").click(function() {

  $("tr:nth-child('+ inputNumber +')").show();

  inputNumber++

});

I can't figure out why this would not work...

Upvotes: 0

Views: 51

Answers (2)

$('tr:nth-child('+ inputNumber +')').show();

Upvotes: 1

Dogbert
Dogbert

Reputation: 222118

You used double quotes in place of single quotes (or the other way round).

$("tr:nth-child('+ inputNumber +')").show();

should be

$('tr:nth-child('+ inputNumber +')').show();

Upvotes: 1

Related Questions