當(dāng)用戶單擊“預(yù)訂”按鈕時(shí),我試圖更改事件的顏色。默認(rèn)情況下,該按鈕設(shè)置為綠色,但希望在單擊時(shí)將其更改為橙色。 $(' #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'); });這是我更新數(shù)據(jù)庫中的類的服務(wù)方法。 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; }任何幫助將不勝感激。
1 回答

MMMHUHU
TA貢獻(xiàn)1834條經(jīng)驗(yàn) 獲得超8個(gè)贊
使用以下內(nèi)容:
document.getElementById("eventBook").style.color= "orange";
假設(shè)您想更改文本顏色。如果你想改變背景顏色,或者背景顏色。
- 1 回答
- 0 關(guān)注
- 162 瀏覽
添加回答
舉報(bào)
0/150
提交
取消