js:
var num = 1;
function showImg() {
document.getElementById("divImg" + n).style.display = 'block';
}
function hideImg() {
document.getElementById("divImg" + n).style.display = 'none';
num++;
}

jsp:
<c:forEach items="${product}" var="product">
<tr>
<td><input type="checkbox" name="box" id=box <%=sum %>
value=${product.id } /></td>
<td>${product.id}</td>
<td><a href="javascript:void(0)" onMouseOut="hideImg()"
onmouseover="showImg()"
>${product.proName}</a> 
<div id="divImg${product.id}" class="divClass"
style="display: none; height: 50px; back-ground: #f00; position: absolute;">
<img src="${basePath}/img/${product.img}">
</div></td>
<td>${product.number}</td>
<td class="am-hide-sm-only">${product.price}</td>
<td class="am-hide-sm-only">${product.des}</td>
<td>
[color=#FF99CC]js中怎么获取我标红了的ID值呢,因为不能直接 var num = ${product.id },所以怎么动态获取div中的值呢?求大牛帮助[/color]

解决方案 »

  1.   

    org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/admin/p_show.jsp at line 3734: <script type="text/javascript">
    35:  var num = 1;
    36:  function showImg() {
    37:  document.getElementById("divImg${product.id}").style.display = 'block';
    38:  }
    39:  function hideImg() {
    40:  document.getElementById("divImg${product.id}").style.display = 'none';
      

  2.   

    给td标签添加name或者id,使用jquery获取td标签下的div元素的id值