【问题标题】:Creating html button link - not working创建 html 按钮链接 - 不起作用
【发布时间】:2011-06-22 15:14:23
【问题描述】:

非常快速的问题。我的模板中有一个这样的 href 链接。

<a href={% url tiptop.views.client_items name.pk %}>add item</a>

这可行,但如果我出于某种原因希望将其创建为按钮,则它不起作用。

<input type="button" on_click="window.location.href='{% url tiptop.views.client_items name.pk %}></a>'" value="Add item">

我不明白为什么它不起作用。基本上,按钮会显示,但是当我单击按钮时它什么也不做。

【问题讨论】:

  • javascript“点击”事件是onclick而不是on_click,也许这就是为什么?

标签: javascript html django templates button


【解决方案1】:

试试:

   <a <!--...your link code here -->
   <input type="button" onClick="window.location.href='{% url tiptop.views.client_items name.pk %}'" value="Add item"/></a>

您的单引号和双引号没有正确关闭。

【讨论】:

  • 好的。实际上,andre matos 所说的也是正确的。事实上,这才是真正的答案。谢谢你们俩。
猜你喜欢
  • 2017-05-23
  • 1970-01-01
  • 2015-01-29
  • 2021-05-26
  • 1970-01-01
  • 2019-04-23
  • 2018-11-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多