你需要jQuery來解決這個問題,添加到該元素,使用一些類爲主動鏈接和使用jquery刪除活動類這是一個方法示例如下
腳本
$('.emp_details_link a').on('click',function(){
$('div').removeClass('active');
$(this).parent().addClass('active');
});
PHP
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/general';?>" >General</a></div>
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/contact';?>" >Contact</a></div>
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/Relations';?>" >Relations</a></div>
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/Work';?>" >Work</a></div>
CSS
.emp_details_link{
border:1px solid #000000;
width:100px;
height:20px;
float:left;
}
.emp_details_link a{
text-decoration:none;
}
.emp_details_link > a:active{ // poiting to the parent div
border:1px solid red;
border-bottom:none;
}
.active
{
border:none;
}
,並用使用jquery出另一種方法,是直接使用的類中適當頁,如我假定現在觸點被激活頁面
css
.emp_details_link{
border:1px solid #000000;
width:100px;
height:20px;
float:left;
}
.emp_details_link a{
text-decoration:none;
}
.emp_details_link > a:active{ // poiting to the parent div
border:1px solid red;
border-bottom:none;
}
.active
{
border:none;
}
PHP
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/general';?>" >General</a></div>
<div class="emp_details_link active"><a href="<?php echo base_url().'index.php/hr/employee_details/contact';?>" >Contact</a></div>
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/Relations';?>" >Relations</a></div>
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/Work';?>" >Work</a></div>
沒有聯繫的有類'active' – 2013-03-14 05:23:48
該解決方案將是對類'active'添加到'div.emp_details_link'而不是錨點元素 – 2013-03-14 05:24:34
我也建議尋找jQuery,因爲我發現這更容易使用,但是,您面對的人在查看時沒有啓用javascript。 – 2013-03-14 05:25:02