daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. s1= new String()
  2. var myArray = new Array();
  3. var div_id=0;
  4.  
  5. myArray[0] = "Donald Duck";
  6. myArray[1] = "Winnie Pooh";
  7. myArray[2] = "Komal Waseem";
  8. myArray[3] = "Hockey";
  9. myArray[4] = "Basketball";
  10. myArray[5] = "Shooting";
  11. myArray[6] = "Mickey Mouse";
  12.  
  13.  
  14. function test(){
  15. s1 = document.getElementById('filter').value;
  16. var myRegex = new RegExp((s1),"ig");
  17. arraysearch(myRegex);
  18. }
  19.  
  20.  
  21.  
  22. function arraysearch(myRegex){
  23. var flag=0;
  24.  
  25. for(b=1; b<=div_id; b++)
  26.     {
  27.    var d = document.getElementById('lc');
  28.    var olddiv= document.getElementById("div" + b);
  29.    if(olddiv){
  30.    d.removeChild(olddiv);}
  31.    }
  32.  
  33. for(i=0; i<myArray.length; i++)
  34. {
  35. if (myArray[i].match(myRegex)){
  36.       div_id++;
  37.       flag=1;
  38.       document.getElementById('lc').style.visibility='visible';
  39.       var element = document.createElement("div");
  40.       element.setAttribute('id', "div" + div_id);
  41.       element.appendChild(document.createTextNode(myArray[i]));
  42.       document.getElementById('lc').appendChild(element);
  43.  
  44.       var x =document.getElementsByTagName("div")
  45.       for(t=0; t<x.length; t++)
  46.       {
  47.       //alert(t);
  48.       if(x[t]){
  49.       x[t].onmouseover = function(){
  50.       x[t].style.backgroundColor='green';
  51.        }
  52.        }
  53. }
  54. }
  55.     if (flag ==0){
  56.     document.getElementById('lc').style.visibility='hidden'; }
  57. }
  58.  
  59.     }
  60.    
  61. x[t].onmouseover = function() {
  62.    this.style.backgroundColor='green';
  63. }
  64.    
  65. div.myDiv:hover {
  66.     background-color: green;
  67. }
  68.    
  69. #mydiv{
  70.      background-color:red;
  71. }
  72.  
  73. #mydiv:hover{
  74.     background-color:green;
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top