2011-06-10 61 views
1

我有被称为像这样我的网页链接:我可以做一个按钮的捷径吗?

<a href="/xxx/" > 
    <button >xxx</button> 
</a> 

我有几个这样的,我想很容易让用户点击,而不必去按钮,用户并单击。我可以给用户一个快捷方式,比如ALT M或者类似于按钮的东西吗?如果用户点击输入,我也可以使按钮成为默认按钮吗?

回答

1

您应该使用accesskey财产

<a href="/xxx/" > 
    <button accesskey="M" >xxx</button> 
</a> 
0

使用accesskey =“1”给元素一个“accesskey”。当用户按下1将激活链接。

编辑

为JavaScript(jQuery的)解决方案见this SO post

+0

根据浏览器和平台,用户按下1加适当的键(alt/meta/ctrl) – Eineki 2011-06-10 11:44:04

+0

@Eineki:这就是所谓的[修饰键](http://en.wikipedia.org/wiki/Modifier_key)。 – Marcel 2011-06-10 11:46:16

0

我会推荐的造型一个div看起来像一个按钮,因为他们以stackoverflow.com上的标签为例

通过stackoverflow.com使用

CSS(需要一些工作!)

.post-taglist { 
    clear: both; 
    margin-bottom: 10px; 
} 
.edit-tags-wrapper > a.post-tag { 
    margin-right: 6px; 
} 
.post-tag, .post-text .post-tag, #wmd-preview a.post-tag { 
    background-color: #E0EAF1; 
    border-bottom: 1px solid #3E6D8E; 
    border-right: 1px solid #7F9FB6; 
    color: #3E6D8E; 
    font-size: 90%; 
    line-height: 2.4; 
    margin: 2px 2px 2px 0; 
    padding: 3px 4px; 
    text-decoration: none; 
    white-space: nowrap; 
} 
post-tag:hover, .post-text .post-tag:hover, #wmd-preview a.post-tag:hover { 
    background-color: #3E6D8E; 
    border-bottom: 1px solid #37607D; 
    border-right: 1px solid #37607D; 
    color: #E0EAF1; 
    text-decoration: none; 
} 

或者你可以用你的按钮表单元素像

<form method="post" action="nextPage.html" > 
<button>Press me</button> 
</form> 

我希望这有助于。

+0

这对我关于访问键的问题的答案有什么帮助?我现在很困惑。 – Maricel 2011-06-10 12:05:12

+0

对不起,当我输入我的答案时,我忘记了那部分内容......访问键的分配方式与Eineki的答案中相同(很明显)忘记了那部分 – Ryan 2011-06-10 12:30:05

相关问题