简体   繁体   English

默认加载DIV Javascript

[英]Default load DIV Javascript

Im trying to build a navigation menu where one side is a male that you click on certain area's (ie the head) and on the left side its show the latest products, plus a break down of that section (shaving, razors, beard grooming etc) 我正在尝试建立一个导航菜单,其中一侧是男性,您单击某个区域(即头部),左侧则显示最新产品,以及该部分的分类(剃须,剃须刀,胡须修饰等) )

My code can be seen here : 我的代码可以在这里看到:

<section class="wr-our-brand">
  <div class="container">
    <div class="containerright">  
      <div id="building">
        <img src="images/nav_text.png"  alt="" usemap="#map" style="padding-top:4em;">    
        <map id="map" name="map">
          <area class="link" shape="rect" alt="" title="" coords="69,3,127,31" data-val="one" target="" />
          <area class="link" shape="rect" alt="" title="" coords="138,182,232,256" data-val="two" target="" />
          <area class="link" shape="rect" alt="" title="" coords="53,313,170,339" data-val="three" target="" />
        </map>
      </div>
    </div>

    <div class="containerleft">    
      <div  id="menu">
        <h2>Hello and Welcome</h2>
        <p style="font-size:16px;">Informational introduction Informational introduction Informational introduction Informational introduction Informational introduction Informational introduction. Informational introduction Informational introduction Informational introduction Informational introduction Informational introduction Informational introduction.<br><br> Informational introduction Informational introduction Informational introduction Informational introduction Informational introduction Informational introduction. Informational introduction Informational introduction Informational introduction Informational introduction Informational introduction Informational introduction.<br>
        <p style="font-size:16px;"><br>To view our wide range of products please select an area on the male outline.</p>

        <div class="tab" id="one">This is Hair</div>
        <div class="tab" id="two">This is two</div>
        <div class="tab" id="three">This is three</div>
      </div>
    </div>
  </div>
</section>

Plus the Java Script here: 加上Java脚本:

  <script type="text/javascript" src="http://code.jquery.com/jquery-git.js"></script>
  <script>
    $(document).ready(function(){
      $(".link").click(function() {
        var which = $(this).data('val');
        $(".tab").hide();    
        $('#'+which).show();        
      });
    });
  </script>

My problem is that I wish for a welcome 'tab' to load without any user interaction (as seen in my code) however dissapear if the use clicks on another tab. 我的问题是,我希望加载一个受欢迎的“选项卡”而没有任何用户交互(如我的代码所示),但是如果使用情况单击另一个选项卡,该选项卡将消失。 At the moment it just sits there and the new information forms below it. 目前,它只是坐在那里,下面是新信息。

Cheers 干杯

UPDATE CSS 更新CSS

#building {
float: right;
} 
 #menu {
float: left;
width: 100%;
overflow: auto;

}
.tab { display:none; }

I wish for a welcome 'tab' to load without any user interaction 我希望在没有任何用户交互的情况下加载一个受欢迎的“标签”

You can do this in css like: 您可以在CSS中执行以下操作:

.tab {  display: none; }

The above css would make the tabs to hide but the welcome would be visible to user without any user interaction. 上面的css将使选项卡隐藏,但是欢迎将对用户可见,而无需任何用户交互。 But you need to make sure the menu div is not explicitly hidden via css. 但是您需要确保menu div没有通过CSS显式隐藏。

I think you should mark the #menu div as position:relative in your css and the tabs should be marked as position:absolute with top:0 and left:0 我认为您应该将#menu div标记为css中的position:relative ,并且选项卡应标记为position:absolutetop:0left:0

Next to that, maybe you should put the welcome in a separate div as well and hide it when you open another tab (or make the welcome also a tab) 紧接着,也许您也应该将欢迎词放在一个separate div中,并在打开另一个选项卡时将其隐藏(或将欢迎词也设为一个选项卡)

In this jsFiddle you can see it working with some modifications (I removed the image map, and put the welcome in a div) 在这个jsFiddle中,您可以看到它进行了一些修改(我删除了图像映射,并将欢迎放在div中)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM