Drupal - 向所有提交按钮添加类
我的网页中有几个表单,我希望能够向所有提交按钮添加一个类(现在我有表单提交作为标准)。而且,在某些表单中,我有使用 AHAH 来显示某些内容的按钮,但我不希望这些按钮具有新类,而只希望那些在表单上进行最终提交的按钮。
提前致谢!
I have several forms in my webpage, and I want to be able to add a class to all my submit buttons (right now I have form-submit as standard). And also, in some forms I have button which uses AHAH in order to show something, but I don't want these to have the new class, only those button who does the final submit on the form.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
或者您可以覆盖负责提交按钮的
theme_button
。将其放入template.php
文件中,并确保在进行更改后清除缓存。您可以var_dump
$element
并查看如何区分提交按钮。Or you can overwrite
theme_button
which is responsible for the submit buttons. Place this in thetemplate.php
file and make sure to clear the cache after you make the changes. You canvar_dump
the$element
and see how you can differentiate between the submit buttons.或者使用 jQuery:
Or use jQuery:
您不需要其他类,只需做出正确的 CSS 选择:
这将仅设置页面上每个表单上最后一个提交按钮的样式。
you don't need other classes, just make the right CSS selection:
this will style only the last submit button on every form on your page.