我正在php中处理基于日期的触发器,并希望使用此代码自动单击一个按钮:
<?php
$oldDate = metadata('item', array('Dublin Core', 'Date'));
$latestDate = explode("/", $oldDate);
$year = $latestDate[2];
$month = $latestDate[1];
$day = $latestDate[0];
$newDate = $month.'/'.$day.'/'.$year;
$newestDate = new DateTime($newDate);
echo $newestDate->format('jS M Y');
$t = time();
$nt = strtotime($newDate);
if($nt <= $t){
} else {
echo "<script> $(document).ready(function(){
$('#gatemodal').trigger('click');
});</script>";
}
?>但是触发器单击事件不会触发。不知道故障出在哪里。我尝试将触发器行更改为以下内容:
$('#gatemodal')[0].click();和
jQuery(document).ready(function(){
jQuery('#gatemodal').trigger('click');还是不能工作。
发布于 2015-07-06 20:49:54
在回显部分,设置一个变量并赋值(例如$fail='1'),然后在你的php文件中检查$fail是否被设置并且等于1,然后让你的脚本。
`<?php if (isset($fail)&& $fail=='1'){ ?>
<script type="text/javascript">
jQuery(document).ready(function(){
$('#gatemodal').trigger('click');
});
</script>";`
https://stackoverflow.com/questions/28559586
复制相似问题