我正在尝试使用 Materialise css 芯片获取数据。但是当我尝试使用表单提交时没有收到任何数据。
添加芯片后,我检查输入字段值是否为空。
我写了一段jquery代码来验证这一点
$('#showvalues').on('click', function(){
alert($('#emotiontags').val())
})
我的芯片代码看起来像
<div class="chips chips-autocomplete col s4 offset-s3">
<input placeholder="You Emotions" id="emotiontags" type="text"
name="emotiontags">
</div>
<button class="btn waves-effect waves-light" id="showvalues">
Show values
<i class="material-icons right">send</i>
</button>
Here is its out with normal text
and here is the output when I try to add chips
已经过去 6 个月了,但我想为遇到这个问题的人提供答案。根据MaterializeCSS的文档,chipsData
是存储当前芯片数据数组的属性。
通过这样的方式获取芯片元素的实例后;
var chipInstance = M.Chips.getInstance($(".chips"));
可以通过以下方式访问芯片阵列并将其记录到控制台
console.log(chipInstance.chipsData);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)