donglanying3855 2014-04-02 01:53
浏览 51
已采纳

更改所选菜单选项卡的颜色

How can I change in my code menu, for change the color of selected menu tab after click? this is my code:

php

<div class="meniu-item" onclick="$('#content').load('_core/home.php?rand='+Math.random()); window.location.hash = 'home';   ">Home</div>
<div class="meniu-item" onclick="$('#content').load('_core/after-login.php?what=help&rand='+Math.random()); window.location.hash = 'help';  ">Contact</div>

css

.meniu-item {
    display:block;
    float:left;
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #fdfdfd), color-stop(1, #f1f1f2) );
    background:-moz-linear-gradient( center top, #fdfdfd 5%, #f1f1f2 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdfdfd', endColorstr='#f1f1f2');
    background-color:#fdfdfd;
    border-right:1px solid #e0e0e0;
    color:#333333;
    font-family:Verdana;
    font-size:10px;
    font-weight:bold;
    padding:4px 0 0 0;
    text-decoration:none;
    text-shadow:1px 1px 0px #ffffff;
    cursor:pointer;
    height:25px;
    color:#4d4d4d;
    width: 97px;
    text-align:center;
    margin-top: 6px;
    line-height: 2;

}

Example:

http://www.codeproject.com/KB/webforms/MenuControlSelectedItem1/EndProduct1.JPG

  • 写回答

1条回答 默认 最新

  • doumi2106 2014-04-02 01:57
    关注

    Something like:

    <div data-uri="_core/home.php" class="meniu-item">Home</div>
    <div data-uri="_core/after-login.php" class="meniu-item">Contact</div>
    

    With the jQuery:

    $("div.meniu-item").on("click", function()
    {
        $('#content').load($(this).data("uri"));
        window.location.hash = $(this).text().toLowerCase();
    
        // Remove the class 'selected' from all navigation items first.
        $("div.meniu-item").removeClass("selected");
    
        // Then add it to the one we clicked.
        $(this).addClass("selected");
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP