从Materialize CSS芯片获取数据 [英] Get data from Materialize css chips

查看:49
本文介绍了从Materialize CSS芯片获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从MaterializeCSS芯片中获取数据,但我不知道如何.

I need get data from MaterializeCSS chips, but I don't know, how.

$('.chips-placeholder').material_chip({
    placeholder: 'Stanici přidíte stisknutím klávesy enter',
    secondaryPlaceholder: '+Přidat',
});

function Show(){ 
    var data = $('.chips-placeholder').material_chip('data');
    document.write(data);
}

<!--Added external styles and scripts-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/css/materialize.min.css">
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

<!--Html body-->

<div class="chips chips-placeholder"></div>
<button onclick="Show()" type="button">Show</button>

感谢您的帮助.

推荐答案

因此,要访问数据芯片,您只需执行以下操作:

So, to access to the data's chip you just have to do this:

var data= $('#id of your chips div').material_chip('data');
alert(data[0].tag);`

"0"是数据的索引(0、1、2、3,...)

'0' is the indexof your data (0, 1, 2 , 3, ...)

标签"是芯片的内容,您也可以使用".id"获取数据的ID.

'tag' is the chip content, you can also get the id of your data with '.id'

这篇关于从Materialize CSS芯片获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆