开发者

Scrolling animation JQuery UI

开发者 https://www.devze.com 2023-04-01 06:42 出处:网络
I\'m using JQuery UI to add a calendar in my web page and I used window.location.href to go to a anchor clicking on a date in the calendar with the

I'm using JQuery UI to add a calendar in my web page and I used

window.location.href

to go to a anchor clicking on a date in the calendar with the

onSelect

event of JQuery UI date picker. Anyone can suggest how to smooth scrolling with JQuery in the onSelect event? The js code is this:

<script type="text/javascript">     
$(function() {
var events = [ 
{ Title: "#DETAILS", Date: new Date("09/13/2011") }, 
{ Title: "Dinner", Date: new Date("09/25/2011") }, 
{ Title: "Meeting with manager", Date: new Date("10/01/2011") }
];

$("#datepicker").datepicker({
beforeShowDay: function(date) {
    var result = [true, '', null];
    var matching = $.grep(events, function(event) {
     开发者_如何学JAVA   return event.Date.valueOf() === date.valueOf();
    });

    if (matching.length) {
        result = [true, 'highlight', null];
    }
    return result;
},
onSelect: function(date) {
       window.location.href = "#"+date;
}
});
});
</script>


Maybe using a jQuery plugin like this one?

[...]
onSelect: function(date) {
       $.smoothScroll({
        scrollTarget: "#"+date
        });
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消