Andrew Smith Andrew Smith - 11 days ago 5
HTML Question

Datepicker icon does not appear next to input textbox

As you can see on the following JS Fiddle, I can only get the small Datepicker Icon to appear next to one of the input boxes. I need it to appear next to both.

However, changing 'id' to 'class' doesn't work, and results in both icons disappearing.

http://jsfiddle.net/Vzt39/

HTML:

<title>jQuery UI Datepicker - Icon trigger</title>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>


<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<script>
$(function() {
$( "#datepicker" ).datepicker({
showOn: "button",
buttonImage: "calendar.gif",
buttonImageOnly: true
});
});
</script>



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


CSS:


<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />


<link rel="stylesheet" href="/resources/demos/style.css" />

Answer
  <script>
  $(function() {
    $( "#datepicker" ).datepicker({
      showOn: "button",
      buttonImage: "calendar.gif",
      buttonImageOnly: true
    });
      $( "#datepicker2" ).datepicker({
      showOn: "button",
      buttonImage: "calendar.gif",
      buttonImageOnly: true
    });    
  });
  </script>
Comments