I have an inputbox that allows the user to search for a contact based on the contact number or contact name and I want the search result display only if it is matched with either name or number. The contact number is storing in the data attribute data-contact-id
and the name is displayed inside label
tag.
But I am stuck here. Below are the simple structure of data.
JSFiddle
$('#input_search').on("keyup", function() {
var user_input = $(this).val().toLowerCase();
// Stuck here
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<div class="search-container">
<input type="text" placeholder="Search for contact" id="input_search">
</div>
<div class="forward-body">
<div class="model" data-contact-id="44">
<label class="label-name">cccc1</label>
</div>
<div class="model" data-contact-id="555888">
<label class="label-name">Jason</label>
</div>
<div class="model" data-contact-id="alibaba
">
<label class="label-name">AliBABA
</label>
</div>
<div class="model" data-contact-id="221222">
<label class="label-name">Wababa wakanda</label>
</div>
<div class="model" data-contact-id="123123
">
<label class="label-name">Alibaba Wababa
</label>
</div>
<div class="model" data-contact-id="9">
<label class="label-name">testing_9</label>
</div>
<div class="model" data-contact-id="6">
<label class="label-name">data_number_6</label>
</div>
<div class="model" data-contact-id="5">
<label class="label-name">data_number5</label>
</div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…