function subStForTable(str,strLen){
   var sb ="";
   if(str.length>strLen){
   sb +='<span title ="'+str+'">'+str.substr(0,strLen)+'...</span>';
   }else{
   sb +='<span title ="'+str+'">'+str+'</span>';
   }
   return sb;
}
我写的一个js的 截取方法

解决方案 »

  1.   

    用td的中一个title属性就可以完成
    <html>
      <body>
       <table>
       <tr>
       <td title="我是一个中国人我爱中国">我是一个............</td>
    </tr>
    </table>
    </body>
    </html>
    相关代码
      

  2.   

    鼠标放上面显示内容的属性是 title;字串截取 一般用fn标签
      

  3.   

    表单怎么调你这个JS方法呢?参数该怎么传呢?  <table width="610" height="25" border="0" cellpadding="0" cellspacing="0" background="image/bg_02.jpg">
              <tr>
                <td><div align="center"><strong>网站广告信息的查询</strong></div></td>
              </tr>
            </table>
            <br>
     <table width="100%"  border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="CCCCCC">
            <tr>
              <td width="15%" height="25"><div align="center">广告编号</div></td>
              <td width="20%"><div align="center">图片名称</div></td>
              <td width="25%"><div align="center">图片地址</div></td>
              <td width="28%"><div align="center">广告链接</div></td>
              <td width="35%"><div align="center">操作</div></td>
            </tr>
          <% for(int i=start;i<over;i++){
                   AdvertisementForm adform=(AdvertisementForm)list.get(i);
              %>
            <tr bgcolor="#FFFFFF">
              <td height="5"><div align="center"><%=adform.getId()  %></div></td>
              <td><div align="center"><%=adform.getImageName() %></div></td>
              <td><div align="center"><%=adform.getImagePath() %></div></td>
               <td><div align="center"><%=adform.getAdPageUrl() %></div></td>
              <td><div align="center">
                <a href="advertisementAction.do?action=2&id=<%=adform.getId() %>">修改</a>&nbsp; &nbsp;    
                <a href="javascript:deleteAdver('<%=adform.getId()%>')">删除</a>   
                                        
               </div></td>
          <%}%> </tr>
          </table>
      

  4.   

    subStForTable("asdasdadadasdadada",5) 直接调用 在你想显示的地方 放入第一个参数 你要现实的 文字 第二个参数 要截取的昌都
      

  5.   

    给我满分吧。 绝对符合你的要求.newsInfo:hover {
    background: #eee;
    color: #333;
    z-index: 999;
    }
    .newsInfo {
    color:black;
    position: relative;
    z-index: 0;
    }  
    .newsInfo span {
    display: none;

     /*设置正常下的span为隐藏状态*/
    .newsInfo:hover span {
    display: block;
    position: absolute;
    min-width:400px;
    top: 28px;
    left:100px;
    border: 1px solid #cccccc;
    background: #fff;
    color: #333;
    padding: 5px;
    text-align: left;
    overflow: hidden;
    }.newInfoTruncation {
    width:300px; 
    white-space:nowrap; 
    word-break:keep-all; 
    overflow:hidden; 
    text-overflow:ellipsis;
    } <html>
    <head>
    <link href="index.css" rel="Stylesheet" type="text/css" />
    </head>
    <body>
    <div>
    <a href="#"class="newsInfo">
    <div class="newInfoTruncation">
    2010年度深圳市因私出入境中介机构信息公布 28家出入境中介机构通过审核
    </div>
    <span>
    2010年度深圳市因私出入境中介机构信息公布 28家出入境中介机构通过审核
    </span>
    </a>
    </div>
    </body>
    </html>