我的代码如下:
<ul id="profileList" class="nav nav-list">
<li><a href="<?php echo base_url('user/signature')?>">修改个人签名档</a></li>
<li><a href="<?php echo base_url('user/location')?>">修改个人居住地</a></li>
<li><a href="<?php echo base_url('user/education')?>">修改个人学校专业</a></li>
</ul>
还有这里的JS代码:
<script type="text/javascript">
$(document).ready(function() {
// store url for current page as global variable
current_page = document.location.href
// apply selected states depending on current page
if (current_page.index(/signature/)) {
$("ul#profileList li:eq(0)").addClass('active');
} else if (current_page.match(/location/)) {
$("ul#profileList li:eq(1)").addClass('active');
} else if (current_page.match(/education/)) {
$("ul#profileList li:eq(2)").addClass('active');
} else { // don't mark any nav links as selected
$("ul#profileList li").removeClass('active');
};
});
</script>
当我单击第二个和第三个 li 项目时,它们运行良好。但是当我单击第一个项目时,该项目没有变为活动状态。出了什么问题,为什么?