我想在顶帽的HTML链接打开js的主要内容区域的折叠到正确的位置。例如,我想要“关于”链接来打开"chirp...“部分。
http://imip.rvadv.com/index2.html
我不太了解js,所以请仔细解释。谢谢。
发布于 2012-07-08 09:21:42
为"about me“链接设置id,如下所示:
<a href="#aboutme" id="aboutme">您还应该向打开"chirp“部分的link元素添加一个id:
<a href="#" id="chirp">Chirp. Would you like to know about me?<h2>Read the official birdwatcher's guide.</h2></a>然后使用jQuery.click() event。正如jQuery文档中所解释的:
click“说明:将事件处理程序绑定到”
“JavaScript事件,或在元素上触发该事件。”
示例:
$("#other").click(function() {
$("#target").click();
});应用于您的页面:
$("#aboutme").click(function() {
$("#chirp").click();
});别忘了用"script“标签包装JS代码:
<script>
$("#aboutme").click(function() {
$("#chirp").click();
});
</script>https://stackoverflow.com/questions/11379929
复制相似问题