PHP函数问题,如何实现导航样式不同切换?
functiondispMenu(){global$user_ID;$adminOps=$this->getAdminOps();$menu="<divid='pm-me...
function dispMenu()
{
global $user_ID;
$adminOps = $this->getAdminOps();
$menu = "<div id='pm-menu'>";
$menu .= "<a class='fep-button href='".$this->pageURL."'>".__("论坛", "cartpaujpm")."</a>";
$menu .= "<a class='fep-button' href='".$this->actionURL."viewannouncements'>".__("博客", "cartpaujpm")."</a>";
$menu .= "<a class='fep-button' href='".$this->actionURL."newmessage'>".__("知道", "cartpaujpm")."</a>";
$menu .= "<a class='fep-button' href='".$this->actionURL."settings'>".__("设置", "cartpaujpm")."</a>";
$menu .= "</div>";
$menu .= "<div id='pm-content'>";
return $menu;
}
如何在点击一个导航时加入另外一个CSS,如下:(current)
<a class='fep-button current'
来实现导航点击后切换到不懂效果..................
我是新手,请告诉教我一下? 展开
{
global $user_ID;
$adminOps = $this->getAdminOps();
$menu = "<div id='pm-menu'>";
$menu .= "<a class='fep-button href='".$this->pageURL."'>".__("论坛", "cartpaujpm")."</a>";
$menu .= "<a class='fep-button' href='".$this->actionURL."viewannouncements'>".__("博客", "cartpaujpm")."</a>";
$menu .= "<a class='fep-button' href='".$this->actionURL."newmessage'>".__("知道", "cartpaujpm")."</a>";
$menu .= "<a class='fep-button' href='".$this->actionURL."settings'>".__("设置", "cartpaujpm")."</a>";
$menu .= "</div>";
$menu .= "<div id='pm-content'>";
return $menu;
}
如何在点击一个导航时加入另外一个CSS,如下:(current)
<a class='fep-button current'
来实现导航点击后切换到不懂效果..................
我是新手,请告诉教我一下? 展开
2个回答
展开全部
用jquery ,给你一个例子, if($("#change_address").hasClass("fold"))
{
//如果change_address有样式 fold
$("#change_address").removeClass("fold"); //移除change_address的样式 fold
}
else
{
//否则添加
$("#change_address").addClass("fold");
}
//根据栏目显示内容 选项卡
//yijiClass 栏目样式名称,添加鼠标移上事件
//conClass 内容样式名称,控制除当前显示/影藏之外的层影藏/显示
//pubId 内容id前缀,当前显示/影藏
function showMenu_head(yijiClass,conClass, pubIdPrefix){
$("."+yijiClass).mouseover(function(){
$("."+conClass).hide();
$("."+yijiClass).removeClass("underlineClass");
$("#"+pubIdPrefix+$(this).attr('id')).show();
$(this).addClass("underlineClass"); //当前栏目下加上下划线
});
}
<div id="nva">
<ul>
<li id="sy" class="sbmenu_sy" style=" background:url(images/nva_bj_left.gif) left no-repeat;"><a href="index.php">首 页</a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva1" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(1); ?>.php?menuId=1"><?php echo ret_menuName(1); ?> </a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva2" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(2); ?>.php?menuId=2"><?php echo ret_menuName(2); ?></a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva3" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(3); ?>.php?menuId=3"><?php echo ret_menuName(3); ?></a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva4" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(34); ?>.php?menuId=34"><?php echo ret_menuName(34); ?> </a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva5" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(35); ?>.php?menuId=35"><?php echo ret_menuName(35); ?></a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva6" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(36); ?>.php?menuId=36"><?php echo ret_menuName(36); ?> </a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva7" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(38); ?>.php?menuId=38"><?php echo ret_menuName(38); ?></a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva8" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(39); ?>.php?menuId=39"><?php echo ret_menuName(39); ?></a></li>
<li style=" width:2px;"> <img src="images/nva_li.png" /></li>
<li id="nva9" class="sbmenu_sy" style="background:url(images/nva_bj_right.gif) right no-repeat;"><a href="<?php echo ret_menuPageName(68); ?>.php?menuId=68"><?php echo ret_menuName(68); ?></a></li>
</ul>
</div>
<div id="ej_nva">
<div id="ej_nva1" class="sbmenu_nva">
<?php
$totleCount=getMenuCount(1);
$num=1;
$sql = "select * from menu where parentID = 1 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?>
</div>
<div id="ej_nva2" class="sbmenu_nva"><?php
$totleCount=getMenuCount(2);
$num=1;
$sql = "select * from menu where parentID = 2 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva3" class="sbmenu_nva"><?php
$totleCount=getMenuCount(3);
$num=1;
$sql = "select * from menu where parentID = 3 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva4" class="sbmenu_nva"><?php
$totleCount=getMenuCount(34);
$num=1;
$sql = "select * from menu where parentID = 34 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva5" class="sbmenu_nva"><?php
$totleCount=getMenuCount(35);
$num=1;
$sql = "select * from menu where parentID = 35 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo "|";
}
$num++;
}?></div>
<div id="ej_nva6" class="sbmenu_nva"><?php
$totleCount=getMenuCount(36);
$num=1;
$sql = "select * from menu where parentID = 36 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva7" class="sbmenu_nva"><?php
$totleCount=getMenuCount(38);
$num=1;
$sql = "select * from menu where parentID = 38 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva8" class="sbmenu_nva"><?php
$totleCount=getMenuCount(39);
$num=1;
$sql = "select * from menu where parentID = 39 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva9" class="sbmenu_nva"><?php
$totleCount=getMenuCount(68);
$num=1;
$sql = "select * from menu where parentID = 68 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
</div>
<script>
showMenu_head("sbmenu_sy","sbmenu_nva","ej_");
</script>
{
//如果change_address有样式 fold
$("#change_address").removeClass("fold"); //移除change_address的样式 fold
}
else
{
//否则添加
$("#change_address").addClass("fold");
}
//根据栏目显示内容 选项卡
//yijiClass 栏目样式名称,添加鼠标移上事件
//conClass 内容样式名称,控制除当前显示/影藏之外的层影藏/显示
//pubId 内容id前缀,当前显示/影藏
function showMenu_head(yijiClass,conClass, pubIdPrefix){
$("."+yijiClass).mouseover(function(){
$("."+conClass).hide();
$("."+yijiClass).removeClass("underlineClass");
$("#"+pubIdPrefix+$(this).attr('id')).show();
$(this).addClass("underlineClass"); //当前栏目下加上下划线
});
}
<div id="nva">
<ul>
<li id="sy" class="sbmenu_sy" style=" background:url(images/nva_bj_left.gif) left no-repeat;"><a href="index.php">首 页</a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva1" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(1); ?>.php?menuId=1"><?php echo ret_menuName(1); ?> </a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva2" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(2); ?>.php?menuId=2"><?php echo ret_menuName(2); ?></a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva3" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(3); ?>.php?menuId=3"><?php echo ret_menuName(3); ?></a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva4" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(34); ?>.php?menuId=34"><?php echo ret_menuName(34); ?> </a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva5" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(35); ?>.php?menuId=35"><?php echo ret_menuName(35); ?></a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva6" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(36); ?>.php?menuId=36"><?php echo ret_menuName(36); ?> </a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva7" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(38); ?>.php?menuId=38"><?php echo ret_menuName(38); ?></a></li>
<li style=" width:1px;"> <img src="images/nva_li.png" /></li>
<li id="nva8" class="sbmenu_sy"><a href="<?php echo ret_menuPageName(39); ?>.php?menuId=39"><?php echo ret_menuName(39); ?></a></li>
<li style=" width:2px;"> <img src="images/nva_li.png" /></li>
<li id="nva9" class="sbmenu_sy" style="background:url(images/nva_bj_right.gif) right no-repeat;"><a href="<?php echo ret_menuPageName(68); ?>.php?menuId=68"><?php echo ret_menuName(68); ?></a></li>
</ul>
</div>
<div id="ej_nva">
<div id="ej_nva1" class="sbmenu_nva">
<?php
$totleCount=getMenuCount(1);
$num=1;
$sql = "select * from menu where parentID = 1 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?>
</div>
<div id="ej_nva2" class="sbmenu_nva"><?php
$totleCount=getMenuCount(2);
$num=1;
$sql = "select * from menu where parentID = 2 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva3" class="sbmenu_nva"><?php
$totleCount=getMenuCount(3);
$num=1;
$sql = "select * from menu where parentID = 3 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva4" class="sbmenu_nva"><?php
$totleCount=getMenuCount(34);
$num=1;
$sql = "select * from menu where parentID = 34 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva5" class="sbmenu_nva"><?php
$totleCount=getMenuCount(35);
$num=1;
$sql = "select * from menu where parentID = 35 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo "|";
}
$num++;
}?></div>
<div id="ej_nva6" class="sbmenu_nva"><?php
$totleCount=getMenuCount(36);
$num=1;
$sql = "select * from menu where parentID = 36 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva7" class="sbmenu_nva"><?php
$totleCount=getMenuCount(38);
$num=1;
$sql = "select * from menu where parentID = 38 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva8" class="sbmenu_nva"><?php
$totleCount=getMenuCount(39);
$num=1;
$sql = "select * from menu where parentID = 39 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
<div id="ej_nva9" class="sbmenu_nva"><?php
$totleCount=getMenuCount(68);
$num=1;
$sql = "select * from menu where parentID = 68 and isShow=0 order by sort asc , id desc ";
mysql_query("set names 'utf-8'",$conn);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
?>
<a href="<?php echo ret_menuPageName($row['id']); ?>_xx.php?menuId=<?php echo $row['id']?>"><?php echo $row['className']; ?></a>
<?php
if($num<$totleCount){
echo " | ";
}
$num++;
}?></div>
</div>
<script>
showMenu_head("sbmenu_sy","sbmenu_nva","ej_");
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询