2
我想激活菜單點擊。我使用引導與codeigniter但是我已經嘗試了很多,但它不工作。 這是我的top_menus.php代碼。激活菜單onclick引導與codeigniter
<div class="navbar-wrapper" style="position: absolute;
top: 0;
right: 0;
left: 0;
z-index: 20;
margin-top: 2px;">
<div class="container">
<div id="menu" class="navbar navbar-inverse navbar-static-top">
<div class="navbar-header">
<button class="btn btn-success navbar-toggle"
data-toggle="collapse"
data-target=".navbar-collapse"><span class="glyphicon glyphicon-chevron-down"></span></button>
<div id="logo">
<a class="navbar-brand" href="<?php echo "index";?>">blog</a>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar" id="mytab">
<li class="nav active"><a id="signup" href="<?php echo "index/signup";?>">Sign up</a></li>
<li class="nav"><a id="sign" href="<?php echo "index/signin";?>">Sign In</a></li>
<li class="nav"><a id="logout" href="<?php echo "index/logout"; ?>">Logout</a></li>
<li class="nav"><a id="new_post" href="<?php echo "index/posts";?>">new post</a></li>
<li class="nav"><a id="show_post" href="<?php echo "index/show_post";?>">Show post</a></li>
<li class="nav"><a id="upload" href="<?php echo "index/upload_form";?>">upload</a></li>
<li class="nav"><a id="contact" href="<?php echo "index/contact";?>">Contact us</a></li>
</ul>
</div>
</div>
</div>
</div>
讓我們假設我點擊登錄,所以它會去signin.php。 這裏是signin.php
<body class="container" style="padding:40px;">
<?php $this->load->view('top_menus'); ?>
<h1> Sign In</h1>
<div class="row">
<div class="col-lg-12">
<?php
if($this->session->userdata('username')!=''){
redirect("index/post");
}
echo form_open("index/verifying");
echo form_input('username','','placeholder="username"');
?>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<?php
echo form_input('password','','placeholder="password"');
echo form_submit('submit','Signin');
echo form_close();
?>
</div>
</div>
<script src="<?php echo base_url();?>js/jquery-2.1.0.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="<?php echo base_url();?>js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>js/tabactivation.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#sign').click(function(e) {
var $this = $(this);
if (!$this.hasClass('active')) {
$this.addClass('active');
}
e.preventDefault();
});
謝謝哥們你真的讓我很快樂,但爲什麼它沒有與我的代碼工作我仍然想知道 –
您提供的代碼對選項卡很好,但不適用於將css類添加到選擇器 –