我很难在填充 div #mcs4_container 后执行 javascript,而是在加载任何内容之前触发它。这是来自 .post() 的处理页面的一部分,所以不幸的是我不能把它放在 (window).load 上,因为窗口已经加载了。 mCustomScrollbar 是一个 jquery 插件,可以为 mcs4_container 中包含的内容添加滚动条。下面是相关的 php:
echo
'<div id="reserveAPickupAppointmentForm6">';
if (mysql_num_rows($result) == 0) {
echo
'There are currently no appointments available online for this date. Please call or email the office to set up a custom time.';
}
else {
echo
'<div id="mcs4_container">
<div class="customScrollBox">
<div class="container">
<div class="content">';
while($row = mysql_fetch_array($result)) {
echo
'<div class = "hoverLive2 reserveAPickupAppointmentDateText reserveAPickupAppointmentButtonText">'
.$row["date"].
'</div>';
}
echo
'</div>
</div>
<div class="dragger_container"><div class="dragger"></div></div>
</div>
</div>';
echo
'</div>';
echo
'<script>
$("#mcs4_container").mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"fixed","yes","yes",10);
</script>';
}
最佳答案
$.post('/whatev', function() {//this is your callback});
如果您使用的是 jQuery,上面的代码应该会为您提供一个回调,该回调会在您的发布请求被填充时触发。
不能 100% 确定这是否是您想要的。
关于php - 在动态填充 div 后让 js 触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9388732/