日期:2014-05-16  浏览次数:20332 次

jquery关于border-bottom-width和eval的问题
function hdmdiy(n)
{

  $("#showcontent").html(eval('str'+n));
  $("#tag1").attr("border-bottom-width","1px");

}


<tr id="newsmenu">
  <td width="145" height="30" style="BORDER-RIGHT: #666666 0px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 0px solid" onmouseover="hdmdiy(1)" id="tag1"><div align="center">要闻</div></td>
  <td width="145" style="BORDER-RIGHT: #666666 0px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 1px solid" onmouseover="hdmdiy(2)" id="tag2"><div align="center">媒体</div></td>
  <td width="145" style="BORDER-RIGHT: #666666 0px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 1px solid" onmouseover="hdmdiy(3)" id="tag3"><div align="center">动态</div></td>
  <td width="145" style="BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 1px solid" onmouseover="hdmdiy(4)" id="tag4"><div align="center">之窗</div></td>
  </tr>


问题1:  attr("border-bottom-width","1px"); 改边框宽度无效果

问题2: 我希望做成根据n值动态定位标签的效果

类似   $(eval("#tag"+n)).attr 正确的应该怎么写

------解决方案--------------------
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://www.liuxiaofan.com/demo/js/jquery-1.6.4.min.js" type="text/javascript"></script>

</head>
<body>
<table>
<tr id="newsmenu">
  <td width="145" height="30" style="BORDER-RIGHT: #666666 0px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 0px solid" onmouseover="hdmdiy(1)" id="tag1"><div align="center">要闻</div></td>
  <td width="145" style="BORDER-RIGHT: #666666 0px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 0px solid" onmouseover="hdmdiy(2)" id="tag2"><div align="center">媒体</div></td>
  <td width="145" style="BORDER-RIGHT: #666666 0px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 0px solid" onmouseover="hdmdiy(3)" id="tag3"><div align="center">动态</div></td>
  <td width="145" style="BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 0px solid" onmouseover="hdmdiy(4)" id="tag4"><div align="center">之窗</div></td>
  </tr>
  </table>
  <div id="showcontent"></div>
<script>
    function hdmdiy(n)
{


  $("#showcontent").html('str'+n);
  $("#tag"+n).css({"border-bottom-width":"1px"});

}
</script>
</body>
</html>