doulin6761 2013-09-18 19:36
浏览 59
已采纳

在索引之外的每个页面上隐藏div

I have ran into a minor problem that I almost found an answer to. I have my header/footer that I made into an include file since the client was making me add and remove stuff to these daily. Now I can do all the changes in one file, boy what a nifty feature! The excitement didn't last long trust me, now I had to find a fix for adding the current or active state for each page's nav, and now I am in a big dilemma. I would like to keep the include files so I don't have to be wasting the clients time with extensive changes but I need to make this div only appear on the index file. The div at the very top that is a dark gray needs to appear on the homepage but hidden on the other pages. It says "Obamacare made easy - Get Professional Help at No Extra Cost!".

Any ideas on how I can achieve this desired effect?

If you need any more parts of the code or anything then just let me know.

Header include besides head section(GA, meta tags, and all that jazz)

</head>

<body>
<div class="hTitle"><em>Obamacare Made Easy – Get Professional Help at No Extra Cost!</em><span class="x">    <strong>X</strong></span></div>
<div class="header">
<div class="wrapper">
    <a href="index.php"><img class="logo" src="images/logo.png" alt="OAHU logo" /></a>
    <a class="fraud" href="http://insurance.ohio.gov/Newsroom/Pages/05092013ConsumerAlertHealthReform.aspx" target="blank">Fraud Alert<br /><p>Click to learn</p></a>
</div>
</div>
<nav>
  <ul>
    <li><a class="current" href="index.php">Home</a></li>
    <li><a href="consumer.php">Find an Agent</a></li>
    <li><a href="resources.php">Resources</a></li>
    <li><a href="about.php">About OAHU</a></li>
    <li><a href="http://www.ohioahu.org/" target="blank">Agent's Login</a></li>
  </ul>
</nav>

jsfiddle file

live site if that helps

The site is written in HTML5, CSS3, jQuery, and PHP so any of those are an option to fix this.

  • 写回答

3条回答 默认 最新

  • dongren4147 2013-09-18 19:43
    关注

    By default, keep that div hidden, .hTitle{ display:none } and use jQuery to show the div and do it only on home page

    $(document).ready(function(){
        if($('a.current').attr('href') == 'index.php') {
            $('.hTitle').show();
        }
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line