如何向所有 Drupal 表单添加 onmouseover 事件?
我想向我的 drupal 网站上所有表单的提交按钮添加一个 onmouseover 事件。
我该怎么做?
本
I want to add an onmouseover event to the submit button of all forms on my drupal site.
How can I do this?
Ben
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 jQuery:
编辑: 使用另一种可能的解决方案进行更新,因为您只需要更新背景颜色。
如果您不关心 IE6 支持,也可以使用
:hover
用于提交按钮的 CSS 伪选择器,不需要任何 javascript。确保所有提交按钮都设置了一个类(在本例中我使用
'submit'
作为类名)。With jQuery:
EDIT: Updated with another possible solution since you just need to update the background color.
If you don't care about IE6 support, you can also use the
:hover
CSS pseudo selector for your submit buttons and don't need any javascript. Make sure all your submit buttons have a class set to them (I'm using'submit'
as the class name in this example).我通过将以下代码添加到自定义模块成功地部分解决了我的问题:
但是,这仅适用于提交按钮,我希望它适用于所有按钮。我尝试将“提交”替换为“按钮”,但随后代码完全停止工作。
I have managed to partly resolve my problem by adding the following code to a custom module:
However, this only works for submit buttons, and I want it to work for all buttons. I've tried replacing 'submit' with 'button' but then the code stops working altogether.