- Jquery click not working on dropdown menu
- <input type='text' id='topicInput' name='topic' autocomplete='off' />
- <div id='tagResult'></div> //this is the dropdown
- $('#topicInput').keyup(function(){
- var topic = $(this).val();
- if (topic==''){
- $('#tagResult').css("display" , "none");
- }
- else{
- //$('div').click(function(){
- //$('#tagResult').css("display" , "none");
- //});
- $('#tagResult').css("display" , "block");
- $.post('../topic.php' , {topic: topic} , function(response){
- $('#tagResult').html(response);
- });
- }
- });
- //the above code is working properly
- $('.topicResult').click(function(){
- alert(1); //this is just a test, but it never shows up
- });
- $(document).on('click','.topicResult',function(){
- alert('1');
- )};
- $('#topicInput').keyup(function(){
- var topic = $(this).val();
- if (topic==''){
- $('#tagResult').css("display" , "none");
- }
- else{
- //$('div').click(function(){
- //$('#tagResult').css("display" , "none");
- //});
- $('#tagResult').css("display" , "block");
- $.post('../topic.php' , {topic: topic} , function(response){
- $('#tagResult').html(response);
- $('.topicResult').click(function(){
- alert(1); //this is just a test, but it never shows up
- });
- });
- }
- });
- $.post('../topic.php' , {topic: topic} , function(response){
- $('#tagResult').html(response);
- $('.topicResult').click(function(){
- alert(1); //this is just a test, but it never shows up
- });
- });