从列表中选取值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从列表中选取值相关的知识,希望对你有一定的参考价值。

  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. $("ul[id='values'] li").click(function suggestValues(){
  10. input = $("input[id='input-text-4']");
  11. el = $(this).html();
  12. $(this).remove();
  13. newinput = input.val();
  14. newinput = (newinput + el + ", ");
  15. input.val(newinput);
  16. });

以上是关于从列表中选取值的主要内容,如果未能解决你的问题,请参考以下文章