我在页面上使用 scrollTo 并希望将功能应用于所有链接。这段代码不应该工作吗?我在这里忘记了什么?
谢谢
<script type="text/javascript">
$(document).ready(function(){
var target = $(this).attr('href');
$('.scrollTo').scrollTo(target);
});
</script>
<li><a class="scrollTo" href="#ref1">Recommendation for Developing and Disseminating Hazard and Exposure Data: The Integrated Tiered Testing and Assessment Approach</a></li>
<div id="ref1">
<h3>REFERENCE 1. Recommendation for Developing and Disseminating Hazard and Exposure Data: The Integrated Tiered Testing and Assessment Approach</h3>
</div>