Html5添加带备忘录功能的简单的日期选择器插件教程

一、安装
bower install simpleeventcalendar

二、Html结构
<table>
<thead>
<tr><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td><td>星期日</td></tr>
</thead>
<tbody>
<tr>
<td date-month="12" date-day="1">1</td>
</tr>
</tbody>
</table>

下面是备忘录的html结构:
<div class="day-event" date-month="12" date-day="16" data-number="1">
<a href="#" class="close fontawesome-remove"></a>
<h2 class="title">Lorem ipsum 3</h2>
<span class="date">2015-01-23</span>
<p>......</p>
<button class="read-more">Read more</button>
</div>

三、调用插件
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
 
<script src="simplecalendar.js"></script>
 
<script src="style.css"></script>


KeyMob移动端广告平台,为广告主提供精准的效果营销和品牌推广服务,为应用开发者在游戏、应用端提供移动广告植入业务,创造更高的广告收益。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用Qt的QCalendarWidget实现一个多功能日历,同时在点击某一天时,在右侧显示出该天的备忘录,并且可以添加、编辑和删除备忘录。以下是一个简单的实现思路: 1. 创建一个包含QCalendarWidget和QListWidget的主窗口。 2. 将QCalendarWidget的信号clicked(QDate date)连接到一个槽函数,该槽函数负责根据日期显示当天的备忘录。 3. 在添加备忘录时,将备忘录文本和日期保存到一个QMap中,其中日期作为键,备忘录文本作为值。 4. 在显示备忘录时,获取当前选中的日期,然后从QMap中读取该日期对应的备忘录文本,并在QListWidget中显示。 5. 在编辑和删除备忘录时,根据用户选择的备忘录项目,获取对应的日期,并在QMap中更新备忘录内容。 以下是一个简单的示例代码,仅供参考: ```cpp #include <QtWidgets> class CalendarWidget : public QWidget { Q_OBJECT public: CalendarWidget(QWidget* parent = nullptr); ~CalendarWidget() override = default; private slots: void onCalendarClicked(const QDate& date); void onAddMemo(); void onEditMemo(); void onDeleteMemo(); private: QCalendarWidget* calendar_; QListWidget* memoList_; QMap<QDate, QString> memos_; void showMemo(const QDate& date); }; CalendarWidget::CalendarWidget(QWidget* parent) : QWidget(parent) { calendar_ = new QCalendarWidget(this); memoList_ = new QListWidget(this); connect(calendar_, &QCalendarWidget::clicked, this, &CalendarWidget::onCalendarClicked); QPushButton* addMemoButton = new QPushButton(tr("Add Memo"), this); connect(addMemoButton, &QPushButton::clicked, this, &CalendarWidget::onAddMemo); QPushButton* editMemoButton = new QPushButton(tr("Edit Memo"), this); connect(editMemoButton, &QPushButton::clicked, this, &CalendarWidget::onEditMemo); QPushButton* deleteMemoButton = new QPushButton(tr("Delete Memo"), this); connect(deleteMemoButton, &QPushButton::clicked, this, &CalendarWidget::onDeleteMemo); QHBoxLayout* buttonLayout = new QHBoxLayout; buttonLayout->addWidget(addMemoButton); buttonLayout->addWidget(editMemoButton); buttonLayout->addWidget(deleteMemoButton); QVBoxLayout* mainLayout = new QVBoxLayout(this); mainLayout->addWidget(calendar_, 1); mainLayout->addWidget(memoList_, 2); mainLayout->addLayout(buttonLayout); } void CalendarWidget::onCalendarClicked(const QDate& date) { showMemo(date); } void CalendarWidget::onAddMemo() { QDate date = calendar_->selectedDate(); QString memo = QInputDialog::getText(this, tr("Add Memo"), tr("Memo Text:")); if (!memo.isEmpty()) { memos_[date] = memo; showMemo(date); } } void CalendarWidget::onEditMemo() { QListWidgetItem* currentItem = memoList_->currentItem(); if (currentItem) { QDate date = calendar_->selectedDate(); QString memo = QInputDialog::getText(this, tr("Edit Memo"), tr("Memo Text:"), QLineEdit::Normal, currentItem->text()); if (!memo.isEmpty()) { memos_[date] = memo; showMemo(date); } } } void CalendarWidget::onDeleteMemo() { QListWidgetItem* currentItem = memoList_->currentItem(); if (currentItem) { QDate date = calendar_->selectedDate(); memos_.remove(date); showMemo(date); } } void CalendarWidget::showMemo(const QDate& date) { memoList_->clear(); if (memos_.contains(date)) { memoList_->addItem(memos_[date]); } } int main(int argc, char* argv[]) { QApplication app(argc, argv); CalendarWidget calendarWidget; calendarWidget.show(); return app.exec(); } #include "main.moc" ``` 在这个示例代码中,我们创建了一个CalendarWidget,它包含了一个QCalendarWidget和一个QListWidget,并且有添加、编辑和删除备忘录的按钮。在点击QCalendarWidget的日期时,会自动显示该日期对应的备忘录。在添加、编辑和删除备忘录时,会自动更新备忘录列表,并保存备忘录内容到一个QMap中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值