Javascript 按下DIV键以参考某个位置
我知道如何使div在被单击时引用一个位置Javascript 按下DIV键以参考某个位置,javascript,html,location-href,Javascript,Html,Location Href,我知道如何使div在被单击时引用一个位置 <div onclick="location.href='newurl.html';" tabindex="0"><a>Text</a></div> 我不想在其他地方编写代码,比如js文件只需将两个侦听器连接到div,然后在onkeydown中检查按下的键: <div onkeydown="if(event.which===32||event.which===13) location.hre
<div onclick="location.href='newurl.html';" tabindex="0"><a>Text</a></div>
我不想在其他地方编写代码,比如js文件只需将两个侦听器连接到
div
,然后在onkeydown
中检查按下的键:
<div
onkeydown="if(event.which===32||event.which===13) location.href='newurl.html';"
onclick="location.href='newurl.html';"
tabindex="0"
>
<a>Islam</a>
</div>
.只需将两个侦听器连接到div
,然后在onkeydown
中检查按下的键:
<div
onkeydown="if(event.which===32||event.which===13) location.href='newurl.html';"
onclick="location.href='newurl.html';"
tabindex="0"
>
<a>Islam</a>
</div>
.只需将两个侦听器连接到div
,然后在onkeydown
中检查按下的键:
<div
onkeydown="if(event.which===32||event.which===13) location.href='newurl.html';"
onclick="location.href='newurl.html';"
tabindex="0"
>
<a>Islam</a>
</div>
.只需将两个侦听器连接到div
,然后在onkeydown
中检查按下的键:
<div
onkeydown="if(event.which===32||event.which===13) location.href='newurl.html';"
onclick="location.href='newurl.html';"
tabindex="0"
>
<a>Islam</a>
</div>
.我不完全确定您想要什么,但可能您正在查找event.keyCode
。它为您提供按键的代码,您可以轻松地检查Enter
和Space
<div onkeydown="if(event.keyCode==13||event.keyCode==32)location.href='newurl.html'; " onclick="location.href='newurl.html';" tabindex="0">Link</div>
链接
我不完全确定您想要什么,但可能您正在查找event.keyCode
。它为您提供按键的代码,您可以轻松地检查Enter
和Space
<div onkeydown="if(event.keyCode==13||event.keyCode==32)location.href='newurl.html'; " onclick="location.href='newurl.html';" tabindex="0">Link</div>
链接
我不完全确定您想要什么,但可能您正在查找event.keyCode
。它为您提供按键的代码,您可以轻松地检查Enter
和Space
<div onkeydown="if(event.keyCode==13||event.keyCode==32)location.href='newurl.html'; " onclick="location.href='newurl.html';" tabindex="0">Link</div>
链接
我不完全确定您想要什么,但可能您正在查找event.keyCode
。它为您提供按键的代码,您可以轻松地检查Enter
和Space
<div onkeydown="if(event.keyCode==13||event.keyCode==32)location.href='newurl.html'; " onclick="location.href='newurl.html';" tabindex="0">Link</div>
链接