Cloning datepicker objects [JQuery]

后端 未结 4 731
温柔的废话
温柔的废话 2021-01-02 12:25

I have an input field that I define as a datepicker through a css class. I now want to clone this input field and have it so the cloned inputs are also datepickers.

4条回答
  •  孤独总比滥情好
    2021-01-02 12:29

    to bad I can't comment anymore on the answer given above, but the code still fales! The datepicker shows up at the cloned input element , but uses the selected date value in the original input field and leaves the cloned input field blank .. Any suggestions?

    edit:

    Using the following code fixed it for me..

    $('.datum',clone).removeClass("hasDatepicker").attr('id',"").datepicker();
    

    ( note that I have cloned a wrapper , and am only targeting the 'datum' input field in that wrapper )

    After removing the class as suggested above , I also remove id of the cloned input element. It's the same as the original, so that's why I was updating the original input field with the selected date in the datepicker box.

提交回复
热议问题