如何使用javascript导航到同一页面中的HTML元素... [英] How to navigate to the HTML element in the same page using javascript...
本文介绍了如何使用javascript导航到同一页面中的HTML元素...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在单击按钮时使用javascript导航到同一页面中具有特定"id"的HTML元素.
例如:
<body>
<div id="navigateHere" >
</div>
<button onclicK="navigate();" />
在上面的代码中,javascript函数navigation()中应该包含什么,因此,单击按钮时,它将导航到ID为'navigateHere'....的'div'元素. >
预先感谢...
解决方案
window.location = "#navigateHere";
I want to navigate to an HTML element having a particular 'id' in the same page using javascript on click of a button.
for example:
<body>
<div id="navigateHere" >
</div>
<button onclicK="navigate();" />
In the above code what should be there in the javascript function navigate() , so that on a click of a button , it will navigate to the 'div' element with an id 'navigateHere'.....
Thanks in advance ...
解决方案
window.location = "#navigateHere";
这篇关于如何使用javascript导航到同一页面中的HTML元素...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文