inserting a row on click jquery

I am struggling to figure out why my code is not working. I have a table with a text field, 2 checkboxes and an add button in a row. I have 4 rows on load, I have a hyperlink when clicked should add a new row at the end of the table. My code is adding the row alternatively starting from the first row. My last row is 4 which I am cloning. The sequence I am getting when click on the link 1,4,2,4,3,4,4,4 I don't understand where I am making a mistake, I have been banging my head for this for last 4-5 hours
$('#add').on("click", function(e) { e.preventDefault(); e.stopPropagation(); $clone = $('#settings tbody tr').filter(":last").clone(true).insertAfter('#settings tbody tr').filter(":last").val(''); I tried this code below from one of the questions in stackoverflow. This one didn't work for me, i don't know why $('#settings tbody tr:last').clone(true).insertAfter('#settings tbody>tr:last'); $('#settings tbody tr:last').val('');
Sorry if this this a stupid question, but what is ""?

以上就是inserting a row on click jquery的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准