jsp 头部选中

头文件:

<div class="header">
<div class="loginout">
  Dear Cloud User, welcome back...
  <span><a href="<%=request.getContextPath() %>/user/login.jsp">login out</a> </span>
</div>
</div>
<div class="bannermenu">
<ul>
   <li id="top0" class="noselect">*</li>
   <li id="top1" class="noselect">*</li>
       <li id="top2" class="noselect"><a href="">*</a></li>
       <li id="top3" class="noselect"><a href="">*</a></li>
  </ul>
</div>

js文件

function getClassNameTop(classNameId){
for ( var i = 0; i < 4; i++)
{
  if (classNameId == i)
   document.getElementById("top"+i).className = "select";
  else
   document.getElementById("top"+i).className = "noselect";
}
}



在其他页面中导入头文件和js文件:

<body>
<div class="container">
<jsp:include page="top.jsp"></jsp:include>

.

.

.

<script type="text/javascript">
getClassNameTop(3);
</script>
</body>

你可能感兴趣的:(jsp 头部选中)