Using jQuery to 'click' a li element

后端 未结 6 1834
误落风尘
误落风尘 2020-12-31 08:01

I have a

    element that dynamically generates the
  • elements and simply want to run a onclick event

    
    
            
6条回答
  •  温柔的废话
    2020-12-31 08:43

    Remove the space in selector

      $("li.searchterm").click(function() {    
       console.log('testing');
    });
    

    and You can also use .on to attach the specific event to the matched elements

      $("li.searchterm").on("click",function() {    
       console.log('testing');
    });
    

    Js Fiddle

提交回复
热议问题