gpt4 book ai didi

javascript - 触发 dayClick of fullCalendar with agendaDay view

转载 作者:行者123 更新时间:2023-11-30 14:08:39 24 4
gpt4 key购买 nike

考虑这个 HTML

<tr class="fc-slot120 ">
<th class="fc-agenda-axis fc-widget-header">4PM</th>
<td class="fc-widget-content">
<div style="position: relative;"></div>
</td>
</tr>

单击 td.fc-widet-content 时,将按预期调用 dayClick 事件。我想将此功能扩展到有时间的 th,以便更轻松地进行超额预订。此代码确实会被调用,但不会触发 dayClick。

$('.fc-agenda-axis.fc-widget-header').click(function() {
$(this).find('td.fc-widget-content').trigger('click');
});

关于如何触发内容 td 上的 dayClick 事件有什么想法吗?如果我直接点击 td.fc-widget-content 元素,dayClick 会按预期触发。

最佳答案

尝试使用 sibling

jQuery(document).ready(function($) {

$('.fc-widget-header').click(function() {
$(this).siblings('.fc-widget-content').trigger('click');
});

$('.fc-widget-content').on('click', function() {
console.log('click')
alert('.fc-widget-content clicked')
})
});
.fc-widget-header {
height: 100px;
width: 100px;
background-color: red;
color:white
}

.fc-widget-content {
height: 100px;
width: 100px;
background-color: blue;
color: white;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr class="fc-slot120">
<th class="fc-agenda-axis fc-widget-header">4PM</th>
<td class="fc-widget-content">
testt
<div style="position: relative;"></div>
</td>
</tr>
</table>

关于javascript - 触发 dayClick of fullCalendar with agendaDay view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54873411/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com