Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.73 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Jquery click not working on dropdown menu
  2. <input type='text' id='topicInput' name='topic' autocomplete='off' />
  3. <div id='tagResult'></div>  //this is the dropdown
  4.        
  5. $('#topicInput').keyup(function(){
  6.  
  7.         var topic = $(this).val();
  8.         if (topic==''){
  9.             $('#tagResult').css("display" , "none");
  10.         }
  11.         else{
  12.             //$('div').click(function(){
  13.                 //$('#tagResult').css("display" , "none");
  14.  
  15.             //});
  16.             $('#tagResult').css("display" , "block");
  17.  
  18.                 $.post('../topic.php' , {topic: topic} , function(response){
  19.  
  20.                 $('#tagResult').html(response);    
  21.                 });
  22.             }
  23.     });
  24.      //the above code is working properly
  25.  
  26. $('.topicResult').click(function(){
  27.     alert(1);   //this is just a test, but it never shows up
  28. });
  29.        
  30. $(document).on('click','.topicResult',function(){
  31.       alert('1');
  32.  )};
  33.        
  34. $('#topicInput').keyup(function(){
  35.  
  36.     var topic = $(this).val();
  37.     if (topic==''){
  38.         $('#tagResult').css("display" , "none");
  39.     }
  40.     else{
  41.         //$('div').click(function(){
  42.             //$('#tagResult').css("display" , "none");
  43.  
  44.         //});
  45.         $('#tagResult').css("display" , "block");
  46.  
  47.             $.post('../topic.php' , {topic: topic} , function(response){
  48.  
  49.             $('#tagResult').html(response);
  50.                 $('.topicResult').click(function(){
  51.                       alert(1);   //this is just a test, but it never shows up
  52.                  });
  53.  
  54.             });
  55.         }
  56. });
  57.        
  58. $.post('../topic.php' , {topic: topic} , function(response){
  59.  
  60.     $('#tagResult').html(response);    
  61.  
  62.     $('.topicResult').click(function(){
  63.         alert(1);   //this is just a test, but it never shows up
  64.     });
  65. });