0

Hello I asked a question about date time: Do browsers no longer support date time picker?

and I feel I kinda got the answer I wanted but not quite the results I wanted. I asked for a simple date time picker and I received that, but I ran into the problem of only one working at a time, and I would like two. Can someone please help me figure out how to get two working?

<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
   $( "#datepicker" ).datepicker();
});
</script>
</head>
<body>

<p>Date: <input type="text" id="datepicker"></p>


</body>
</html>
Community
  • 1
  • 1
T Neate
  • 403
  • 2
  • 6
  • 18

1 Answers1

1

Just call datepicker() for each element that you want it applied to

$( "#datepicker1" ).datepicker();
$( "#datepicker2" ).datepicker();
$( "#datepicker3" ).datepicker();

better yet add a class to all elements you want as a datetime picker and call it as:

$( ".customclass" ).datepicker();

Even made a codepen demonstration

code
  • 1,127
  • 7
  • 14