Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html lang=en>
- <head>
- <title>Belajar Jquery dan Ajax</title>
- <style type="text/css">
- ul {
- list-style: none;
- padding: 0;
- margin: 0;
- }
- .highlight {
- background-color: yellow;
- margin-right: 30%;
- }
- </style>
- </head>
- <body>
- <p><input id="search_name" type="text" /></p>
- <ul id="names">
- <li>firdaus</li>
- <li>kausar</li>
- <li>siti</li>
- <li>sari</li>
- </ul>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- $('#search_name').keyup(function(){
- search_name = $(this).val();
- $('#names li').removeClass('highlight');
- if (jQuery.trim(search_name) != ''){
- $("#names li:contains('" + search_name + "')").addClass('highlight');
- }
- });
- });
- </script>
- </body>
- <html>
Advertisement
Add Comment
Please, Sign In to add comment