放映后将焦点设置在 div 内?
Setting focus to anchor inside div after show?
我正在尝试将焦点设置到隐藏 div 元素内的锚元素,同时单击另一个锚 link。我尝试了几个选项,如 .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 中尝试过......它的工作......
也许你的问题是别的
我正在尝试将焦点设置到隐藏 div 元素内的锚元素,同时单击另一个锚 link。我尝试了几个选项,如 .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 中尝试过......它的工作...... 也许你的问题是别的