Why isn't Jquery date picker icon showing in I

2019-08-30 04:17发布

问题:

I have the following code in my html page. The icon exists and the path to the image is valid. Every browser seem to display this correctly except IE8 which only shows a rey box. Does anyone know a way around that?

<script type="text/javascript" charset="utf-8">

 var sDate = new Date(1323637200000);

  $(function() {
    $( "#datepicker" ).datepicker({

      minDate: -151,
      maxDate: "-1D",
      dateFormat: "dd-mm-yy",
      defaultDate: sDate,
      firstDay: 6,
      showOn: "button",
      buttonImage: "/public/images/ico-calendar.gif",
      buttonImageOnly: false,
      onSelect: function(mydate) {
            window.location.href="/reports/"+mydate;
        }
    });
  });
</script>
<input type="hidden" id="datepicker" />

回答1:

After a lot of fiddling I discovered that resetting the maximum width on the icon image allowed the icon to appear correctly. That sounds like a quirk with IE 8.

img{
 max-width: none;
}


回答2:

change the html to

<input type="text" id="datepicker" />

Fiddle here. I have not given a valid image path. You need to check it on your dev system.