I need to put the "autofocus" attributes on hyperlink elements like this:
<a href="mywebsite.com" autofocus focus="javascript code">my link</a>
It seems that "autofocus" works only on input elements.
But the focus event works on hyperlink elements.
Maybe I need to change something on my hyperlink elements?
答案 0 :(得分:1)
根据https://www.w3schools.com/tags/att_autofocus.asp,<a>
标签不能具有“自动对焦”属性。
但是,通过使用jQuery,可以:
<script>
document.getElementById("myId").focus();
</script>