gpt4 book ai didi

javascript - 节目结束后将焦点设置为锚定在 div 内?

转载 作者:行者123 更新时间:2023-11-27 22:44:14 25 4
gpt4 key购买 nike

我试图将焦点设置到隐藏 div 元素内的 anchor 元素,同时单击另一个 anchor 链接。我尝试过几个选项,例如 .focus()、.focusin()。但没有任何效果。

我的代码:

    <script>
$(document).ready(function(){
$("#clickShow").on('click', function(){
$("#showDescription").show();
$("#showDescription").find("a").focus();
});
});
</script>
<div>
<a href="#" id="clickShow">View Hidden Text</a>
</div>

<div id="showDescription" style="display:none;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap <a href="#">Link Text</a> into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>

我想知道,我在这里缺少什么来完成它?

感谢您的帮助。

最佳答案

实际上它正在工作!使用jquery 2.1.1

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#clickShow").on('click', function(){
$("#showDescription").show();
$("#showDescription").find("a").focus();
});
});
</script>
<div>
<a href="#" id="clickShow">View Hidden Text</a>
</div>

<div id="showDescription" style="display:none;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap <a href="http://www.google.com">Link Text</a> into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>

编辑:也在 1.11.1 中尝试过...它的工作...也许您的问题是别的问题

关于javascript - 节目结束后将焦点设置为锚定在 div 内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38523980/

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