javascript - How to hide an element when certain tabs is shown - Stack Overflow

I am using Twitter Bootstrap, and had successfully implemented the tabs. I have a button that should di

I am using Twitter Bootstrap, and had successfully implemented the tabs. I have a button that should display on all the tabs except for one, any idea how should I do that?

<div class="span6 offset1"> 
  <div class="tabbable">
    <ul class="nav nav-tabs">
      <li class="active"><a href="#general" data-toggle="tab">General</a></li>
      <li><a href="#example2" data-toggle="tab">Example2</a></li>
      <li><a href="#example3" data-toggle="tab">Example3</a></li>
    </ul>

    <div class="tab-content">
      <div id="general" class="tab-pane fade in active" >
       //content
      </div>
      <div id="example2" class="tab-pane fade" >
       //content
      </div>
      <div id="example3" class="tab-pane fade" >
       //content
      </div>
    </div>
 </div> 
 <input type="submit" style="width:120px" class='btn btn-primary' id="update" value="Update"/> 
</div>

How do I program it such that when tab example3 is shown, the update button will be hidden, but still remains on page when tab general and example2 is shown.

Thanks!

I am using Twitter Bootstrap, and had successfully implemented the tabs. I have a button that should display on all the tabs except for one, any idea how should I do that?

<div class="span6 offset1"> 
  <div class="tabbable">
    <ul class="nav nav-tabs">
      <li class="active"><a href="#general" data-toggle="tab">General</a></li>
      <li><a href="#example2" data-toggle="tab">Example2</a></li>
      <li><a href="#example3" data-toggle="tab">Example3</a></li>
    </ul>

    <div class="tab-content">
      <div id="general" class="tab-pane fade in active" >
       //content
      </div>
      <div id="example2" class="tab-pane fade" >
       //content
      </div>
      <div id="example3" class="tab-pane fade" >
       //content
      </div>
    </div>
 </div> 
 <input type="submit" style="width:120px" class='btn btn-primary' id="update" value="Update"/> 
</div>

How do I program it such that when tab example3 is shown, the update button will be hidden, but still remains on page when tab general and example2 is shown.

Thanks!

Share Improve this question edited Feb 27, 2020 at 17:39 isherwood 61.2k16 gold badges122 silver badges170 bronze badges asked Apr 19, 2012 at 9:39 revolverrevolver 2,4055 gold badges25 silver badges40 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

I am not sure that is there any event being fired in bootstrap tabs. But the simplest way can be to use mouseclick event on example3 link or even you can try to trigger custom event.

$('a[href="#example3"]').on('click',function(){
 $("#update").hide();
});

use .style.display = 'none'

e.g.

document.getElementById(id).style.display = 'none';

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745229770a4617624.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信