jquery - Datetimepicker did not work on element that append form javascript -


i have 1 input date, input append js this

    var inputdate = '<input type="text" name="date[]" class="form-control date" placeholder="input date"';     $("form").append(inputdate); 

and html code :

    <form method="post">        ...     </form> 

initialize datetimepicker

$('.date').datetimepicker({        format: 'yyyy-mm-dd' }); 

the input element append succesfully , other form have input date work datetimepicker. element append js not showing datetimepicker, there mistakes?

i think missed 1 thing here.

var inputdate = '<input type="text" name="date[]" class="form-control date" placeholder="input date"'; 

it should have > @ end of string.

the initialization code should reexecuted after append inputdate $('form').

so code should be:

var inputdate = '<input type="text" name="date[]" class="form-control date" placeholder="input date">';  $("form").append(inputdate);  $('.date').datetimepicker({format: 'yyyy-mm-dd'}); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -