Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

live search javascript

<form id="live-search" action="" class="styled" method="post">
    <fieldset>
        <h1>Live Search</h1>
        <input type="text" class="text-input" id="filter" placeholder="search" />
        <span id="filter-count"></span>
    </fieldset>
</form>

<nav>
    <ul class="liveSearchBar">
        <li><a href="#">Jim James</a></li>
        <li><a href="#">Hello Bye</a></li>
        <li><a href="#">Wassup Food</a></li>
        <li><a href="#">Contact Us</a></li>
        <li><a href="#">Bleep bloop</a></li>
        <li><a href="#">jQuery HTML</a></li>
        <li><a href="#">CSS HTML AJAX</a></li>
        <li><a href="#">HTML5 Net Set</a></li>
        <li><a href="#">Node Easy</a></li>
        <li><a href="#">Listing Bloop</a></li>
        <li><a href="#">Contact HTML5</a></li>
        <li><a href="#">CSS3 Ajax</a></li>
        <li><a href="#">ET</a></li>
    </ul>
</nav>
.liveSearchBar, .liveSearchBar li{
  margin:0;
  padding:0;
  list-style:none;
}
.liveSearchBar, .liveSearchBar li a{
  color:#fff;
  text-decoration:none;
}
body{
  margin:0;
  background: #01B4FF;
  color:#fff;
  font-weight: 700;
  font-family: 'Brush Script MT', cursive;
  font-size: 20px;
}
#live-search fieldset{
  border:0;
  padding-left:0;
}
:focus{
  outline:none;
}
.text-input{
  height:30px;
  background: none;
  border:1px solid #fff;
  padding:5px ;
  font-family: 'Brush Script MT', cursive;
  font-size: 20px;
  color:#fff;
}
::-webkit-input-placeholder {
     color: #fff;
  }
  
  :-moz-placeholder { /* Firefox 18- */
     color: #fff;  
  }
  
  ::-moz-placeholder {  /* Firefox 19+ */
     color: #fff;  
  }
  
  :-ms-input-placeholder {  
     color: #fff;  
  }

$(document).ready(function(){
    $("#filter").keyup(function(){
 
        // Retrieve the input field text and reset the count to zero
        var filter = $(this).val(), count = 0;
 
        // Loop through the comment list
        $("nav ul li").each(function(){
 
            // If the list item does not contain the text phrase fade it out
            if ($(this).text().search(new RegExp(filter, "i")) < 0) {
                $(this).fadeOut();
 
            // Show the list item if the phrase matches and increase the count by 1
            } else {
                $(this).show();
                count++;
            }
        });
 
        // Update the count
        var numberItems = count;
        $("#filter-count").text("Number of Filter = "+count);
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: Get element by ID with only a partial string 
Javascript :: anagram 
Javascript :: javascript comparison operators 
Javascript :: javascript change input value jquery 
Javascript :: javascript ip address 
Javascript :: how to disable strict mode on object in javascript 
Javascript :: js event on change focus 
Javascript :: get user agent in js 
Javascript :: children javascript 
Javascript :: working with json in javascript 
Javascript :: Date toLocaleDateString Javascript 
Javascript :: for in loop js 
Javascript :: Could not resolve project :react-native-iap mergedebugassets 
Javascript :: foreach in react 
Javascript :: angularjs 1.5.6 cdn 
Javascript :: This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native. 
Javascript :: redux packages 
Javascript :: application pool angular 8 
Javascript :: react cdn 
Javascript :: how to apply border to table in angular 
Javascript :: add new database mongodb 
Javascript :: Saber si un elemento existe en el DOM 
Javascript :: react router dom v6 
Javascript :: js nuxt read/set cookie 
Javascript :: jsjs trigger window error 
Javascript :: keycloak api get an user by exact username 
Javascript :: Not Found The requested URL was not found on this server angular routing when going back to site from ecternal source 
Javascript :: fetch data with axios in reactjs 
Javascript :: code intialization problem javascript 
Javascript :: DC League of Super-Pets 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =