Thursday, 27 October 2016

Onclick anchor tag that value insert into input text / onclick insert value in textbox / add value using jquery

  •  Onclick anchor tag that value insert into input text
  • Jquery code mandatory in bottom not header
  • Wherever use that code I explained into UL inside also


<ul  class="dropdown-menu listofcustomers">
                <input type="text" class="searchbox" id="searchlist"    />
                            <li><a href="#">Option 1</a></li>
                            <li><a href="#">Option 2</a></li>
                            <li><a href="#">Option 3</a></li> 
                            <li><a href="#">Option 4</a></li>
                           
                    </ul>
                   
                    <!-- need to change based on your version -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script type="text/javascript">
$('.listofcustomers a').click(function() {
  var value = $(this).text();
  var input = $('#searchlist');
  input.val(value );
  return false;
});
</script>

No comments:

Post a Comment