简体   繁体   中英

Need help adding events to a Javascript Calendar

I'm trying to create a simple event calendar that has a changing background for each month. I have looked at fullCalendar, but couldn't figure out how to add a background to each month. So I found this calendar code: http://www.java2s.com/Code/JavaScript/GUI-Components/Calendarwithimageforeachmonth.htm

I'm using the above code, and I've modified it to create a different background for each month. Now all I need to do is add about 8 events to the calendar. I know that fullCalendar does this via the following code:

    $(document).ready(function() {

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    $('#calendar').fullCalendar({
        editable: true,
        events: [
            {
                title: 'All Day Event',
                start: new Date(y, m, 1)
            },
            {
                title: 'Long Event',
                start: new Date(y, m, d-5),
                end: new Date(y, m, d-2)
            },
            {
                id: 999,
                title: 'Repeating Event',
                start: new Date(y, m, d-3, 16, 0),
                allDay: false
            },
            {
                id: 999,
                title: 'Repeating Event',
                start: new Date(y, m, d+4, 16, 0),
                allDay: false
            },
            {
                title: 'Meeting',
                start: new Date(y, m, d, 10, 30),
                allDay: false
            },
            {
                title: 'Lunch',
                start: new Date(y, m, d, 12, 0),
                end: new Date(y, m, d, 14, 0),
                allDay: false
            },
            {
                title: 'Birthday Party',
                start: new Date(y, m, d+1, 19, 0),
                end: new Date(y, m, d+1, 22, 30),
                allDay: false
            },
            {
                title: 'Click for Google',
                start: new Date(y, m, 28),
                end: new Date(y, m, 29),
                url: 'http://google.com/'
            }
        ]
    });

});

I am relatively new to editing/learning javascript, so I'm not sure where to begin. I am trying to incorporate that fullCalendar code into the calendar that I've modified from the code in the above link.

For example, I want to add "Independance Day" to July 4th.

Any help is much appreciated!

Thanks!

You just need to add an event to a specific date you want to . like,

 events: [
        {
            title: 'Independence Day',
            start: new Date(2014, 06, 4)
        }];

This will add a event for the independence day to your calendar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM