简体   繁体   English

如何使用JQuery编辑MDL按钮的文本

[英]How to Edit the text of a MDL Button with JQuery

I am currently working on a project which uses MDL Lite and is basically a controller for a device I am building. 我目前正在研究一个使用MDL Lite的项目,该项目基本上是我要构建的设备的控制器。 The webpage has buttons, all defined as standard MDL Buttons with Ripple. 该网页具有按钮,所有按钮均定义为带有波纹的标准MDL按钮。

I need to make the button's text change when something happens. 发生某些情况时,我需要更改按钮的文本。 The problem is, however, when every is use JQuery to change the html of the button (specifically the text displayed), the ripple effect vanishes. 问题是,但是,当每种方法都使用JQuery更改按钮的html (特别是显示的文本)时,波纹效果消失了。

After some research I found this . 经过研究,我发现了这一点 The solution does work but I have exactly 29 buttons, and downgrading then upgrading them each causes a lot of lag. 该解决方案确实有效,但是我只有29个按钮,降级然后升级它们会导致很多滞后。

Is there any other way to fix this problem which doesn't cause lag? 是否有其他方法可以解决此问题而不会导致延迟?

After looking at the real-time HTML updates in Chrome, I noticed the mdl-buttom only adds a span for the ripple effect, with the text right before it. 在查看了Chrome中的实时HTML更新之后,我注意到mdl-buttom只为涟漪效果添加了一个跨度,其前面mdl-buttom是文本。

A simple fast workaround is change the button's text by modifying the html before the child element . 一个简单的快速解决方法是,通过修改child元素之前的html来更改按钮的文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM