Dynamic element onclick event


I am trying to link all my list element to respond upon click event. The list elements will be created dynamically on my JS.

The list element does not respond correctly to the onclick function. I have created a static list element for testing, and even that is not responding.

// search.html
<form class="search" >
  <input id="searchAddress" type="text" name="q" placeholder="Search address"  />
  <ul class="results" id="addressListID">
    <li id="2"><a href="index.html">6 Cashew Crescent<br><span>6 Cashew Crescent. (S)679751</span></a></li>

$( "#addressListID" ).on( "click", "li", function( event ) {
    console.log( $( this ).text() );


I don't actually see the problem. You might forgot to link the JQuery. I tested it and it works properly.


I found out that it was actually my .CSS type that is hindering the way.


I have commented out the part that is causing the error. You can have a look at the commented out portion.