[英]slidetoggle jquery won't display
I just wanted to ask why is it when im using jsfiddle to construct a ul li structured archives with slidetoggle, year>month>title it WORKS, but when I am to apply it to my archives section, only the year and month works, the titles won't display, do css have a problem with this? 我只是想问为什么当我使用jsfiddle来构建带有Slidetoggle的ul结构化档案时,year> month>将其命名为WORKS,但是当我将其应用于我的档案部分时,只有年份和月份有效,标题不会显示,css对此有问题吗?
<?php
include("connection/connect.php");
$sql2 = mysqli_query($con, "SELECT DISTINCT YEAR(post_date) FROM posts ORDER BY YEAR(post_date) DESC");
echo "<div id='nav'><ul>";
while($row2 = mysqli_fetch_assoc($sql2)){
foreach ($row2 as $year) {
echo "<li class='current'><b>$year</b><ul>"; //year
$sql3 = mysqli_query($con, "SELECT DISTINCT MONTH(post_date) FROM posts WHERE YEAR(post_date)='$year' ORDER by MONTH(post_date) DESC");
while($row3 = mysqli_fetch_assoc($sql3)){
foreach ($row3 as $month) {
echo "<li><a style='text-transform: none; color:#333; font-size: 14px;'>".date('F', mktime(0, 0, 0, $month, 1, 2000))."</a><ul>"; //month
$sql4 = mysqli_query($con, "SELECT * FROM posts WHERE MONTH(post_date)='$month' AND YEAR(post_date)='$year' ORDER by post_date DESC");
while($row4 = mysqli_fetch_assoc($sql4)){
$title2 = $row4['post_title'];
echo "<ul><li><a style='text-transform: none; color:#333; font-size: 12px;' href='pages.php?id={$row4['post_id']}'>".$title2."</a></li></ul>";//title
}
}
echo "</ul></li>"; //end month
}
echo "</ul></li>"; //end year
}
}
echo "</ul></div>";
}
?>
in jsfiddle this is how it looks like 在jsfiddle中,它是这样的
2014 2014年
January 一月
February 二月
March <<(clicked and the titles displayed) 三月<<(单击并显示标题)
title 1 标题1
title 2 标题2
in my archives section this is how it looks like 在我的档案部分,它是这样的
2014 2014年
January 一月
February 二月
March <<(clicked yet the titles won't display) 三月<<(单击,但标题不会显示)
by the way here is the code for the script: 顺便说一下,这里是脚本的代码:
$(document).ready(function() {
$("#nav ul li:not(:has(li.current))").find("ul").hide().end() // Hide all other ULs
.click(function() {
if (event.target==this) {
$(this).children('ul').slideToggle('fast');
return false;
}
});
});
I hope you could help me on this, thank you in advance. 希望您能对此有所帮助,在此先感谢您。
You may kindly check my fiddle, Jquery Slidetoggle 您可以检查一下我的小提琴Jquery Slidetoggle
at last, I was able to get the answer.. I added an excess tag near the title and that's the reason why it doesn't display, upon removing it, now my archives work very good. 终于,我得到了答案。。我在标题附近添加了一个多余的标签,这就是为什么在删除它后不显示它的原因,现在我的档案非常好。
<?php
include("connection/connect.php");
$select_posts = "SELECT post_id,post_date,post_title, YEAR(post_date) AS YEAR, MONTH(post_date) AS MONTH, COUNT(*) AS postCount FROM posts";
$run_posts = mysqli_query($con, $select_posts);
while ($row = mysqli_fetch_array($run_posts)){
$sql2 = mysqli_query($con, "SELECT DISTINCT YEAR(post_date) FROM posts ORDER BY YEAR(post_date) DESC");
echo "<div id='nav'><ul>";
while($row2 = mysqli_fetch_assoc($sql2)){
foreach ($row2 as $year) {
echo "<li class='current'><b>$year</b><ul>"; //year
$sql3 = mysqli_query($con, "SELECT DISTINCT MONTH(post_date) FROM posts WHERE YEAR(post_date)='$year' ORDER by MONTH(post_date) DESC");
while($row3 = mysqli_fetch_assoc($sql3)){
foreach ($row3 as $month) {
echo "<li><a style='text-transform: none; color:#333; font-size: 14px;'>".date('F', mktime(0, 0, 0, $month, 1, 2000))."</a><ul>"; //month
$sql4 = mysqli_query($con, "SELECT * FROM posts WHERE MONTH(post_date)='$month' AND YEAR(post_date)='$year' ORDER by post_date DESC");
while($row4 = mysqli_fetch_assoc($sql4)){
$title2 = $row4['post_title'];
echo "<li><a style='text-transform: none; color:#333; font-size: 12px;' href='pages.php?id={$row4['post_id']}'>".$title2."</a></li>";//title
}
}
echo "</ul></li>"; //end month
}
echo "</ul></li>"; //end year
}
}
echo "</ul></div>";
}
?>
Anyway, thanks to those who tried to bear with my problem. 无论如何,感谢那些试图忍受我的问题的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.