工作中碰到的一些东西

1.table 隔行换色  table tbody tr{
     background-color: expression(this.sourceIndex%2==0?'#ffffff':'#f5f7f8');
   }

 

2. jquery 基本语法:

<html>
 <head>
 <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
 <script type="text/javascript">
   
  

  $(document).ready(function(){//防止文档在完全加载(就绪)之前运行 jQuery 代码。  

  $("p").click(function(){
     $(this).hide();
   });
   
   $("#modify").click(function(){
    alert("******");
   });
   
  });
 </script>
 </head>
 <body>
   <input type="button" value=" 修改 " id="modify">
   <p>If you click on me, I will disappear.</p>
 </body>
</html>

 

3.选中checkbox

 var modifyCodingId="";
 function modifyInfo(){
 var checkBoxName=document.getElementsByName("IDS");
 var idsStr="";//记录选中的复选框CaremaID
  for(var i = 0;i < checkBoxName.length;i ++){
   if(checkBoxName[i].type.toLowerCase()=="checkbox"){
    if(checkBoxName[i].checked==true){
     if(idsStr==""){
      idsStr = checkBoxName[i].value;
     }else{
      idsStr += "," + checkBoxName[i].value;
     }
    }
   }
  }
 
  if(idsStr.indexOf(",")>0||idsStr==""){
   alert("请选择一条您要修改的记录!");
   return false;
  }else{
   alert("!");
    document.location.href="<%=request.getContextPath() %>/caseListAction.do?method=getAuditInfo&id="+id;
  }
 }
 
  //选中所有的checkbox
 function TotalCheck(){
  var checkBoxName = document.getElementsByName("IDS");
  for(var i = 0;i < checkBoxName.length;i ++){
   if(checkBoxName[i].type.toLowerCase()=="checkbox"){
    if(checkBoxName[i].checked==true){
     checkBoxName[i].checked=false;
    }else{
     checkBoxName[i].checked=true;
    }
   }
  }
 }

 

4.js中获取request.getContentPath();

 <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

在单独的javascript中不能使用<%= basePath%>类似这样的java  script所以,只能用javascript来获取此context path.
可以用下面的代码来实现。

var localObj = window.location;

var contextPath = localObj.pathname.split("/")[1];

var basePath = localObj.protocol+"//"+localObj.host+"/"+contextPath;

var server_context=basePath;

posted @ 2014-01-21 18:29  Dhyanas  阅读(122)  评论(0编辑  收藏  举报