简体   繁体   English

Material Design - 使用 jQuery 设置输入

[英]Material Design - set input with jQuery

I have edit form, made with material design and I set input with jquery我有编辑表单,用材料设计制作,我用 jquery 设置输入

$("#item").val('value') $("#item").val('value')

But then it has this effect.但它有这个效果。 Until I edit it with a keyboard, js from material design "thinks" there is no text in inputs.在我用键盘编辑它之前,材料设计中的 js “认为”输入中没有文本。

I tried triggering events like .change(), .keyup() or keypress(), it didn't work.我尝试触发诸如 .change()、.keyup() 或 keypress() 之类的事件,但没有奏效。

Thanks for any help or tips.感谢您提供任何帮助或提示。

Here is a DEMO这是一个演示

script:脚本:

$("#sample1").val('TEST').parent('.mdl-textfield').addClass('is-dirty').removeClass('is-invalid');

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

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