title: cant get jquery href value into input box
body: <p>I have been trying to create a rough autocomplete input box and am almost there. However, getting stuck at a certain point. Do check the code before i identify the problem.</p>
  
  <p>JS</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  function getres(){
  var x = document.getElementById("cit");
  $('#resdiv').fadeIn('fast').load('results.php?cit='+x.value);
  }
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
  $("#resdiv a").click(function(){
      var value = $(this).html();
      var input = $('#cit');
      input.val(value);
          $('#resdiv').fadeOut('fast'); 
  });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Some CSS</p>
  
  <pre><code>&lt;style&gt;
  a{text-decoration:none}
  a:link{color:#446666;}
  a:hover{background-color:blue;padding:5px;margin:10px;color:white}
  &lt;/style&gt;
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;input type="text" name="" id="cit" onkeyup="getres()"&gt;
  
  &lt;div id="resdiv"&gt;
  &lt;a href="#" class="test"&gt;Test 1&lt;/a&gt;
  &lt;a href="#" class="test"&gt;Test 2&lt;/a&gt;
  &lt;a href="#" class="test"&gt;Test 3&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>PHP (results.php)</p>
  
  <pre><code> &lt;?php
  if(isset($_GET['cit'])){$cit= $_GET['cit'];}
  include('connnew.php');
  $getprops=$clientdb-&gt;query("SELECT * FROM cities WHERE city LIKE '%$cit%'")  or die ($clientdb-&gt;error);
  while($info=$getprops-&gt;fetch_assoc()){
  
         echo "&lt;a href='#' class='test'&gt;$info[city]&lt;/a&gt;&lt;br&gt;";
  
      //echo "&lt;a href='#' style='text-decoration:none;'&gt;$info[city]&lt;/a&gt;&lt;br&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>My problem is, though everything works, when I click on the hrefs Tes1, Test2 and Test3, the input box #cit gets filled with the value, but not the values of href populated by the PHP into the same #resdiv !</p>
  
  <p>Why is it so ? WIll the click function of jquery work only on hrefs written as text ? And not on the populated hrefs ?</p>