Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
dynamically add the row in the html jquery
var counter = 0;
$(document).ready(function(){
    
    
    $(".add").click(function(){
       
        var divm = "<div class='row form-group '></div>";
        var methodargs= "methodargs"+counter;
        var labelvar = "<div class='col-sm-2 col-form-label'><label for='arguments'>Method Arguments</label></div>";
        var inputkey = "<div class='col-sm-3'><input type='text' placeholder='KEY' id='arguments' class='form-control key' required></div>";
        var inputvalue= "<div class='col-sm-3'><input type='text'  placeholder='VALUE' id='arguments' class='form-control val' required></div>";
        var  addbtn = "  <div class='col-sm-2'><button type='button' class='btn btn-small btn-primary '>Add</button></div>";
        var  delbtn = " <div class='col-sm-2'><button type='button'  class='btn btn-small btn-danger '>delete</button></div>";
       $(divm).addClass(methodargs).append(labelvar).append(inputkey).append(inputvalue).append(addbtn).append(delbtn).insertAfter(".methodargs")
       var key="key"+counter;
       var value="value"+counter;

       $(".key").attr("name",key);
       $(".val").attr("name",value);
       $(".btn-primary").addClass("add");
       $(".btn-danger").addClass("delete")
       counter++;
        
    })

    $(".delete").click(function()
    {   
        console.log("Hello world");
        counter--;
        var currentdel = ".methodargs"+counter;
        $(currentdel).remove();
        console.log(currentdel);
    })

})

Problems: Why dynamically added row buttons add and delete are not working ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!