gpt4 book ai didi

javascript - Jquery 将用户定向到特定的 anchor 标记

转载 作者:可可西里 更新时间:2023-11-01 14:58:24 26 4
gpt4 key购买 nike

如果我知道描述我正在寻找的内容的话,我相信我可以搜索这个。

我有一个链接,当按下该链接时,使用 href="#anchorTagName"将用户定向到另一个 anchor 标记...但是该链接还有一个 onclick 函数,它使包含 anchorTagName 的 div 可见。因此,用户永远不会被定向到 anchor 标记,因为它们以错误的顺序触发。

那么如何让 div 先可见,然后将用户定向到 anchor 标记?

最佳答案

希望这就是您想要做的......

<html>
<head>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.4.2.min.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
$('#theAnchorTheUserClicks').click(function(e) {
e.preventDefault(); //prevent the default click action
$('#divToShow').show('fast',function() { //show the div
$('#newText').focus(); //set the focus where you want
});
});
});
</script>
</head>
<body>
<a id='theAnchorTheUserClicks' href='#newAnchor'>click me</a>
<div style='display:none' id='divToShow'>
<a id='newAnchor'>Here I am!</a>
<input type='text' id='newText'></input>
</div>
</body>
</html>

关于javascript - Jquery 将用户定向到特定的 anchor 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3256780/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com