JQuery DatePicker OnSelect加载图像

时间:2011-03-16 12:22:36

标签: jquery asp.net-mvc

asp.net Mvc和jquery相当新。

让以下代码正常工作,但我想在每次触发datepicker的onSelect时加载图像src。任何帮助非常感谢。

<script type="text/javascript">
    $(function() {
    $('#datepicker').datepicker({ 
                onSelect: function(date,inst) {
                    alert(date)},                                       
                inline: true
            });
        });        
</script>

<h2>Select a date to view the diary:</h2>

<div id="datepicker">        
</div>

<div id ="diary">                                
    <img src="<%=Url.Action("Image", new { id = DateTime.Now.ToString("dd-MM-yyyy") }) %>" alt="" />
</div>

1 个答案:

答案 0 :(得分:0)

$('#datepicker').datepicker({ 
   onSelect: function(date,inst) {
                    $('#diary img').attr('src', <new image path> );
      },                                       
   inline: true
});