jquery html need help

jquery html need help



  1. $(document).ready(function(){

  2. $(".iconClass").click(function(){
  3.  $("#iconSearch").html("<div class=\"btn-group\"><input type=\"search\" id=\"searchInput\"/><span id=\"searchClear\" class=\"glyphicon glyphicon-remove-circle\"></span></div>"); 
  4. });

  5. $("#searchClear").click(function(){
  6.   
  7.     $("#searchInput").val('');
  8. });
  9. });

  10. HTML CODE

  11. <div id="iconSearch">
  12. <i class="fa fa-2x fa-search iconClass"></i>
  13.   <!--Text -->
  14.   <div id="desText">
  15.   <p>Click search icon</p>
  16.   </div> 
  17. </div>

When I run this code it doesn't work. I am trying to make an input whenever user click on the x button at the end of the input, the text in the input get cleared.

This is my first post sorry if i missed something.