-3

I currently have one table and added 2 rows with 2 columns.

Beside this table there is a +plus button. How can I make it so when I click on the plus button, that a new row is added.

allenski
  • 1,652
  • 4
  • 23
  • 39
Mahesh
  • 9
  • 1
  • Firstly you haven't asked a question, or even described the issue you're facing. Secondly, please don't use W3Schools. Their articles are often outdated and sometimes just plain wrong. – Rory McCrossan Mar 21 '18 at 10:28
  • 1
    Maybe this guy just does not understand how to phrase his question because not as good with english? – allenski Mar 26 '18 at 23:25
  • 1
    Hope this helps https://stackoverflow.com/questions/171027/add-table-row-in-jquery – Waleed Mar 27 '18 at 15:13
  • @Waleed, yes that would be the jQuery approach – allenski Mar 27 '18 at 15:17

1 Answers1

1

Does this help: https://jsfiddle.net/zew7d8p1/26/

var button = document.getElementById('niceButton');

button.addEventListener('click',function(e){

    var table = document.getElementById('niceTable');
    var row = table.insertRow(0);

    var td1 = row.insertCell(0);
    var td2 = row.insertCell(1);

    td1.innerHTML = 'new cell';
    td2.innerHTML = 'new cell';

},false);
allenski
  • 1,652
  • 4
  • 23
  • 39