2011-12-03 6 views

답변

0

확인 자동 완성 제어 AutoCompleteBox뿐만 아아 언급 사용에 addtion에서

0

//JQuery: 
 
//mobile - netbanking search 
 
$(document).on('keyup', '#filter', function (e) { 
 
\t // Retrieve the input field text and reset the count to zero 
 
\t var filter = $(this).val(); 
 

 
\t //Regex created to find value in list. 
 
\t var pattern = new RegExp(filter, "i"); 
 

 

 
\t // Loop through the comment list 
 
\t $(".list").each(function() { 
 
\t \t // If the list item does not contain the text phrase fade it out 
 

 
\t \t //Trim space from variable value. 
 
\t \t var str = $(this).text().trim(); 
 

 
\t \t if (str.search(pattern) < 0) { 
 
\t \t \t $(this).fadeOut(); 
 
\t \t \t //Show the list item if the phrase matches and increase the count by 1 
 
\t \t } else { 
 
\t \t \t $(this).show(); 
 
\t \t } 
 
\t }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
JQuery Solution: 
 
HTML will be: 
 

 
<div class="yourlist"> 
 

 
\t <input name="" id="filter" type="text" placeholder="Search list" onkeyup="this.setAttribute('value', this.value);" value=""> 
 

 
\t \t <div class="list" style="display: block;"> 
 
\t \t \t Abc 
 
\t \t </div> 
 
\t \t <div class="list" style="display: block;"> 
 
\t \t \t xyz 
 
\t \t </div> 
 
\t \t <div class="list" style="display: block;"> 
 
\t \t \t qwe 
 
\t \t </div> 
 
</div>

관련 문제