单击全历时单击“书本”按钮时如何更改事件的颜色

问题描述 投票:0回答:1

当用户单击“书本”按钮时,我试图更改事件的颜色。默认情况下,该按钮设置为绿色,但希望单击时将其更改为橙色。

            $(' #eventBook').click(function () {
                var json = {
                    'Id': $('#eventBookId').val(),
                    'Title': $('#eventBookTitle').val(),
                    'Start': $('#eventBookStart').val(),
                    'End': $('#eventBookEnd').val(),
                    'AllDay': $('#eventBookAllDay').is(":checked") ? true : false,
                    'Description': $('#eventBookDescription').val(),
                    'Color': "Orange"//$('#eventBookColor').val()
                };

                console.log('Updating event json', json);
                $.ajax({
                    type: "POST",
                    url: '/TimeTable/BookEvent',
                    data: json,
                    dataType: 'json',
                    success: function (data) {
                        //refresh the calender
                        FetchEventsAndRenderCalendar();
                    },
                    error: function () {
                        alert('Booking Could not be Saved');
                    }
                });
                // close Modal
                $('#eventModal').modal('hide');

            });

这是我的服务方法,用于更新数据库中的类。

        public bool BookEvent(TimeTableEvent t)
        {
            var existing = db.TimeTableEvents.Where(a => a.Id == t.Id).FirstOrDefault();
            if (existing != null)
            {
                existing.Title = t.Title;
                existing.Start = t.Start;
                existing.End = t.End;
                existing.Description = t.Description;
                existing.Color = "Orange";
                existing.AllDay = t.AllDay;
                db.SaveChanges();
                return true;
            }
            return false;
        }

任何帮助将不胜感激。

c# html asp.net .net-core asp.net-ajax
1个回答
0
投票

使用以下内容:

document.getElementById("eventBook").style.color= "orange";

假设您要更改文本颜色。如果您想更改背景色,则使用backgroundcolor。

© www.soinside.com 2019 - 2024. All rights reserved.