基于 JS 的 Web 应用程序中按钮的标记

发布于 2024-11-30 00:53:12 字数 392 浏览 7 评论 0原文

我看到有人说锚点和输入按钮之间的区别很明显。通常在简单的网络表单上,它确实是经过精心设计和干燥的。但是,在使用 Web 应用程序时,通常将链接(即直接转发到另一个页面)作为按钮更有意义,有时并不清楚应该是什么。

遵循应用程序的基础,基本上任何执行任何操作(移动到另一个屏幕、保存工作、获取帮助等)的命令都是一个按钮。

实际考虑的是使用不会将用户重定向到另一个看起来很奇怪的页面的锚点;但是从锚元素调用 javascript 更好吗?

通常,网络应用程序中的按钮嵌套在 li 项目中,并且在 stackoverflow 中请注意,“询问问题”按钮/链接位于列表中,即使它是唯一的项目(我认为这是为了获取正确的样式)。

在为交互式 JS 应用程序编写 html 元素方面的代码时,我应该考虑哪些选项和注意事项?

I have seen it said that the distinction between anchors and input buttons is obvious. Often on simple webforms it's indeed pretty cut and dried. But when working with web applications, often a link (ie direct forwarding to another page) makes more sense as a button and sometimes it's not clear what something ought to be.

Following the basis of applications, where basically any command that does anything (moving to another screen, saving work, getting help etc) is a button.

There's the practical consideration of using anchors that don't redirect the user to another page seeming strange; but is it better to call javascript from an anchor element?

Often buttons in web-apps are nested in li items, and in stackoverflow notice the 'Ask Question' button/link is in a list even though it's the only item (I assume this is to grab the correct styling).

What options and considerations should I take into account in coding the html element side of things for an interactive JS app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮萍、无处依 2024-12-07 00:53:12

IMO,锚点适用于当您移动到不同的屏幕时,特别是当您要更新 URL 哈希以启用后退按钮支持时。因此,如果操作是查看项目或转到编辑页面等,请使用链接。

否则,对于“删除”、“保存”、“取消”等操作,我会使用按钮。

IMO, anchors are for when you are moving to a different screen, especially if you are going to update the URL hash to enable back button support. So if the action is to view an item, or go to the edit page, etc. use a link.

Otherwise for actions such as 'delete', 'save', 'cancel' etc. I would use buttons.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文