0
在scrollTop事件的情况下,(scrollTo)带字符串的值返回为[object htmltablerowelement],而带数字的(scrollTo)值返回为数字本身。 (scrollTo)值正确地使用字符串滚动,数值为 的(scrollTo)值无法正常运行。数值不作为对象返回htmltablerowelement
好心帮助解决
String stdNo = request.getAttribute("pValueAction").toString();
<html>
<div>
<table>
<tr id='stdNo'>....</tr>
</table>
</div>
</html>
<script type="text/javascript">
var m = <%=stdNo%>,
container = $('div'),
scrollTo = $(m);
alert(m);
container.animate({
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()
});
</script>
谢谢Santhucool,但m返回值而不是对象htmltablerowelement – jj2422
@ jj2422 m只会返回值,因为您正在读取从jsp获得的值。你的问题不清楚。为什么你需要物体而不是价值? – Santhucool