Skip to content

Instantly share code, notes, and snippets.

@equivalent
Forked from phoebebright/index.html
Created September 28, 2020 15:16
Show Gist options
  • Select an option

  • Save equivalent/2a18a96b99f2dc2eec81d890f2efc5ee to your computer and use it in GitHub Desktop.

Select an option

Save equivalent/2a18a96b99f2dc2eec81d890f2efc5ee to your computer and use it in GitHub Desktop.

Revisions

  1. @phoebebright phoebebright created this gist Jul 18, 2018.
    14 changes: 14 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <div class="row">
    <div class="col s12">
    <div class="row">
    <div class="input-field col s13">
    <i class="material-icons prefix">textsms</i>
    <input type="text" id="autocomplete" class="autocomplete" >
    <label for="autocomplete">Autocomplete</label>
    </div>
    </div>
    </div>
    </div>

    ID: <p id="key"></p>
    <button class="btn" onclick="getId()">Get</button>
    7 changes: 7 additions & 0 deletions materialize-autocomplete-with-id.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    Materialize AutoComplete with id
    --------------------------------


    A [Pen](https://codepen.io/arg3ni5/pen/ygpZLx) by [Fabian Chinchilla ](https://codepen.io/arg3ni5) on [CodePen](https://codepen.io).

    [License](https://codepen.io/arg3ni5/pen/ygpZLx/license).
    21 changes: 21 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    $(document).ready(function() {
    $('.modal').modal();
    $('select').material_select();
    $('input.autocomplete').autocomplete2({
    data: [
    {id:1,text:'Apple',img:'http://placehold.it/250x250'},
    {id:2,text:'Microsoft',img:'http://placehold.it/250x250'},
    {id:3,text:'Google',img:'http://placehold.it/250x250'},
    ]
    });
    });

    function getId() {
    alert($('#autocomplete').data('id'));
    }






    2 changes: 2 additions & 0 deletions scripts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    <script src="https://codepen.io/arg3ni5/pen/VPQZwe"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    1 change: 1 addition & 0 deletions styles
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css" rel="stylesheet" />