gpt4 book ai didi

javascript - PHP 包含在 jQuery next() 冲突中

转载 作者:太空宇宙 更新时间:2023-11-03 18:34:02 24 4
gpt4 key购买 nike

如果您看一下:http://jsfiddle.net/Qw75j/7/你会看到我在寻找什么。

不过,我希望能够在每个 DIV 中包含 PHP。如果我将 PHP 包含在第一个 DIV 中,PHP 似乎加载得很好,但如果我将 PHP 也放在第二个 DIV 中,或者只是放在第二个或第三个 DIV 中,next() 功能就会中断。目标是在用户点击“下一个”或“上一个”后显示不同的日历月。

我有四种协同工作的资源。用于索引的 HTML/PHP,用于 next() 功能的 jQuery,以及用于某些日历代码的 PHP 和 CSS。

如何在每个与 next() 相关的 DIV 中嵌入单独的 PHP 页面?

预先感谢您的帮助。我真的很难过。

index.php:

<DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/style2.css" />
<script src="http://code.jquery.com/jquery-latest.min.js" ></script>
</head>
<body>

<button id="prev" disabled="disabled">Prev</button>
<button id="next">Next</button>

<div id="cal1" class="first current">
<?php echo '<span class="monthName">'.$nmonth.' '.$cyear.'</span>';
echo draw_calendar($cmonth,$cyear); ?>
<span class="prevMonth"></span>
</div>

<div id="cal2">
<?php echo '<span class="monthName">'.$nmonth.' '.$cyear.'</span>';
echo draw_calendar($cmonth,$cyear); ?>
<span class="prevMonth"></span>
</div>

<div id="cal3" class="last">
<?php
echo '<span class="monthName">'.$nmonth.' '.$cyear.'</span>';
echo draw_calendar($cmonth,$cyear); ?>
<span class="prevMonth"></span>
</div>

</body>
<script>
$('#next').click(function() {
$('.current').removeClass('current').hide()
.next().show().addClass('current');
if ($('.current').hasClass('last')) {
$('#next').attr('disabled', true);
}
$('#prev').attr('disabled', null);
});

$('#prev').click(function() {
$('.current').removeClass('current').hide()
.prev().show().addClass('current');
if ($('.current').hasClass('first')) {
$('#prev').attr('disabled', true);
}
$('#next').attr('disabled', null);
});
</script>
</html>

日历.php:

<html>
<head>
<link rel="stylesheet" type="text/css" href="calendar.css" />
</head>
</html>
<?php
/* draws a calendar */
function draw_calendar($month,$year){

/* draw table */
$calendar = '<table cellpadding="0" cellspacing="0" class="calendar">';

/* table headings */
$headings = array('SUN','MON','TUES','WED','THURS','FRI','SAT');
$calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>';

/* days and weeks vars now ... */
$running_day = date('w',mktime(0,0,0,$month,1,$year));
$days_in_month = date('t',mktime(0,0,0,$month,1,$year));
$days_in_this_week = 1;
$day_counter = 0;
$dates_array = array();

/* row for week one */
$calendar.= '<tr class="calendar-row">';

/* print "blank" days until the first of the current week */
for($x = 0; $x < $running_day; $x++):
$calendar.= '<td class="calendar-day-np"> </td>';
$days_in_this_week++;
endfor;

/* keep going with days.... */
for($list_day = 1; $list_day <= $days_in_month; $list_day++):
$calendar.= '<td class="calendar-day">';
/* add in the day number */
$calendar.= '<div class="day-number"><a href="">'.$list_day.'</a><input type="hidden" name="day" value="'.$list_day.'"></div>';

/** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/
$calendar.= str_repeat('&nbsp',2);

$calendar.= '</td>';
if($running_day == 6):
$calendar.= '</tr>';
if(($day_counter+1) != $days_in_month):
$calendar.= '<tr class="calendar-row">';
endif;
$running_day = -1;
$days_in_this_week = 0;
endif;
$days_in_this_week++; $running_day++; $day_counter++;
endfor;

/* finish the rest of the days in the week */
if($days_in_this_week < 8):
for($x = 1; $x <= (8 - $days_in_this_week); $x++):
$calendar.= '<td class="calendar-day-np"> </td>';
endfor;
endif;

/* final row */
$calendar.= '</tr>';

/* end the table */
$calendar.= '</table>';

/* all done, return result */
return $calendar;
}
$cmonth = date('m');
$nmonth = date('F');
$cyear = date('Y');
?>

日历.css:

@font-face {
font-family:Gotham-Medium;
src: url(./css/GothamMedium.ttf);
}
@font-face {
font-family:Gotham-Light;
src: url(./css/Gotham-Light.ttf);
}
@font-face {
font-family:Gotham-Bold;
src: url(./css/Gotham-Bold.otf);
}
/* calendar */
td.calendar-day {
min-height:30px;
font-size:11px;
position:relative;
background:#000;
}
* html div.calendar-day {
height:30px;
font-family:Gotham-Medium;
}
td.calendar-day-np {
background:#000;
min-height:30px;
}
* html div.calendar-day-np {
height:30px;
}
td.calendar-day-head {
background:#000;
color:#BBA324;
font-family:Gotham-Medium;
font-size:12px;
text-align:center;
width:60px;
padding:5px;
padding-bottom:20px;
border:0;
}
div.day-number {
background:transparent;
color:#fff;
font-family:Gotham-Medium;
font-size:12px;
margin:0 5px -10px 15px;
width:30px;
text-align:center;
padding-top:5px;
padding-bottom:5px;
}
div.day-number:hover {
background:#BBA324;
}
/* shared */
td.calendar-day, td.calendar-day-np {
width:30px;
padding:5px;
border:0;
}
.monthName {
font-family:Gotham-Medium;
color:#BBA324;
font-size:16px;
margin-top:-5px;
text-transform:uppercase;
}
#usTitle {
font-family:Gotham-Light;
font-size:12vw;
text-transform:uppercase;
text-align:center;
}
.plusMonth {
font-family:Gotham-Medium;
color:#000;
font-size: 10px;
float:right;
margin-top: 5px;
}
.prevMonth {
font-family:Gotham-Medium;
color:#000;
font-size: 10px;
float:left;
margin-top: 2px;
text-transform: uppercase;
}
.arrow {
font-family:Gotham-Light;
margin-bottom: 5px;
}
#cal2,#cal3{
display:none !important;
}

最佳答案

在您的calander.css 中删除以下代码

#cal2, #cal3 {
display: none !important;
}

关于javascript - PHP 包含在 jQuery next() 冲突中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19148493/

24 4 0
文章推荐: c# - 要列出的 ListView 项目(字符串)
文章推荐: jquery - 使用
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com