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

382
Views
jquery datepicker does not work on appended elements

I am trying to make all original and appended elements as a date picker but only the original works

I tried this code but next line of inputs appears just as a normal input not a jquery datepicker hope you can find a solution thanks.

Here is my code.

<html>
<head>
    <title></title>
</head>
<script type="text/javascript">


$(document).ready(function(){

    $(".inputdate").datepicker({


    });

    $(".samplebtn").click(function(){

        $(".samplediv").append("<input class='inputdate' type='text' name='date'>");

    });

});

</script>

<body>
    <div class="samplediv">
        <input class="inputdate" type="text" name="date">
    </div>
    <button class="samplebtn">Add</button>
</body>
</html>
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

After bind dynamic item re initialize date picker.

$(".samplebtn").click(function() {
    $(".samplediv").append("<input class='inputdate' type='text' name='date'>");
    $('.samplediv').find(".inputdate").datepicker({

    });
}); 
about 4 years ago · Santiago Trujillo Report

0

You should attach .datepicker() to those new elements. Try this for your .append() script:

$(".samplediv")
.append("<input class='inputdate' type='text' name='date'>")
.promise()
.done(function() {
    $(this).find('.inputdate').datepicker({ ... });
});

Hope this help. :D

about 4 years ago · Santiago Trujillo Report
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!