English 中文(简体)
如何使html纽顿与联系行为联系起来?
原标题:What is the best way to make html button with link behavior?

我有大约50个字。 每一行都有联系,但我需要用纽顿取代这一联系。 我这样做有几条路要走,但我不知道什么方式是最好的。

首先:

<form method="POST" action="some url">
   <input type="submit" value="Clickable Button">
</form>

第二:

<input type="button" value="Action button"
onclick="window.location= http://www.w3schools.com " />

第三:

<input type="button" class="actionButton" value="Action button"
data-link="http://www.w3schools.com"/>

之后,我将加上“ j”法。

$("input.actionButton").click(function () {
   window.location = $(this).attr("data-link");
});

因此,最好的方式是什么?

最佳回答

在这3个国家中,I d 采用了form。 虽然每一环节都有不同之处,但许多形式只是复制链接功能。

但我有第四个选择: 形成联系而不是取而代之。 你可以把这一联系仅仅看看看你想要的是什么方式,包括几乎完全像一个纽州。 由于“is 链接,这将是最先调校准的选项(而且标记不全)。 但显然,这取决于以下原因:你必须把这一联系替换为纽托邦,例如,如果存在一些功能性要求,而不是表面要求这样做。

问题回答

采用一种形式似乎是最审慎的正确方式。 除此以外,它不需要任何 j。 我将首先发言。 你可以把隐蔽的田地列入这一表格,以向服务器传递额外的价值。

如果它是一个应该像一个纽州这样的联系,我将使用一个<条码><a>标签,像一个 but子一样:

/* See http://www.w3.org/TR/CSS2/fonts.html and search for system fonts */
/* See http://www.w3.org/TR/css3-color/#css-system and search for system colors */

.button {
  display: inline-block;
  cursor: default;
  font: small-caption;
  color: buttontext;
  background-color: buttonface;
  border: 2px outset buttonface;
  padding: 1px 6px;
  text-decoration: none;
}
<p>
  <a href="#" class="button">View</a>
  <a href="#" class="button">Cancel</a>
</p>

同意,第一种方式是主观上正确的,一种是没有 Java字典的,但我还是会采取第二种或第三的方式(取决于你是否还需要在其他地方做 j)。 凭借其职能,你可以发挥比仅仅调整方向更大的功能。 我不知道,如果你可能面临在那里增加功能的要求,那么你就可以保持这种可能性。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签