[英]Scroll to top when checkbox is selected
I just wanted to know how I could get the page scrolled to top when checkbox is selected using jQuery or JavaScript, knowing that there is some Angular JS code in there. 我只是想知道当使用jQuery或JavaScript选中复选框时如何将页面滚动到顶部,因为我知道其中有一些Angular JS代码。
<div class="checkbox-list">
<div class="checkbox box-collapse-color" ng-repeat="Type in Types">
<span class="count pull-right">{{Type.count}}</span>
<input type="checkbox"
ng-click="addCompanyType(Type.ac)"
id="checkbox1-c-{{$index}}" />
<label class="check" for="checkbox1-c-{{$index}}">
<span>{{Type.ac}}</span>
</label>
</div>
</div>
Thanks in advance. 提前致谢。
The easiest way is the following: 最简单的方法如下:
$window.scrollTo(0, 0);
It seems the code should be placed into your addCompanyType
function, but I can't say definitely. 似乎代码应该放在您的addCompanyType
函数中,但是我不能肯定地说。 I'd suggest looking at Angular JS ng-checked
directive. 我建议看看Angular JS ng-checked
指令。 Do not forget to inject $window
. 不要忘记注入$window
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.