jQuery传参

<a href="#" onClick="click_scroll('here1');">滚动到here1</a>
<a href="#" onClick="click_scroll('here2');">滚动到here2</a>
<script type="text/javascript">
function click_scroll(a) {
var e = $('#'+a);
var scroll_offset = e.offset();
$("body,html").animate({scrollTop:scroll_offset.top},300);
}
</script>

<div style="height:500px" ></div>
<div id="here1">点击后滚动到here1</div>
<div id="here2">点击后滚动到here2</div>

注意的是:函数内的$(this)是不可以用的;
原文地址:https://www.cnblogs.com/ziyandeyanhuo/p/5477706.html