Reputation: 777
I am using this timepicker: http://labs.perifer.se/timedatepicker/ for one of my intrasite I am enabling the timepicker as mentioned in the example by using
<select id="change_type">
<option value="1">Time</option>
<option value="2">Text</option>
</select>
<input type="text" id="time1" size="10">
$("#time1").timePicker();
Based on a dropdown list I want to make the field time1 as either time/simple text. Is there a way where I can remove the time picker to make the field as simple text?
TIA
Bittu
Upvotes: 1
Views: 7292
Reputation: 11
I'm using this one:
var element = document.getElementById("TIME-PICKER-ID");
var clonedElement = element.cloneNode(true);
var parentElement = element.parentNode;
parentElement.replaceChild(clonedElement, element);
Upvotes: 0
Reputation: 5613
You can use $('.time-picker').remove()
to remove the time-picker function from your page.
Upvotes: 0
Reputation: 6435
How about having two fields, one plain and one datepicker()'ed, and hide/show them as needed?
Alternatively, consider the jQuery UI datepicker, which has a destroy
method which resets the target element.
Upvotes: 0
Reputation: 3830
I would try using Javascript to simply remove the #time1 field then add in a new one with the same ID, setting its value (and any attributes) to the same as the original.
Upvotes: 2