Posted By

stancox on 10/22/09


Tagged

list li pick


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jirimelcak


Pick values from a list


 / Published in: jQuery
 

URL: http://woorkup.com/2009/10/14/jquery-lessons-how-to-interact-with-html-forms/

  1. <!-- HTML -->
  2. <input type="text" id="input-text-4" size="40"/>
  3. <ul id="values">
  4. <li>Smashing Magazine</li>
  5. <li>Woork Up</li>
  6. <li>Mashable</li>
  7. </ul>
  8.  
  9. //JavaScript
  10. $("ul[id='values'] li").click(function suggestValues(){
  11. input = $("input[id='input-text-4']");
  12. el = $(this).html();
  13. $(this).remove();
  14. newinput = input.val();
  15. newinput = (newinput + el + ", ");
  16. input.val(newinput);
  17. });

Report this snippet  

You need to login to post a comment.