jQuery-向列表中添加值-在客户端渲染 [英] jquery - adding a value to a list - rendering on the client side

查看:462
本文介绍了jQuery-向列表中添加值-在客户端渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用rails,我创建了一个显示的列表和一个带有"add"按钮/链接的文本字段. 我希望能够将在文本字段中输入的值添加到列表-在客户端.
我该怎么做?

Using rails, I have created a displayed list and a textfield with a "add" button/link . I want to be able to add the value entered in the text field to the list - on the client side.
How can I do it?

或者如果我可以将我定向到链接以供进一步阅读

or if I you can direct me to a link for further reading

谢谢.

推荐答案

您可以使用jQuery appendTo编写类似这样的内容. http://api.jquery.com/appendTo/

You can use jQuery appendTo you can write something like this. http://api.jquery.com/appendTo/

val = $('#textbox').val();
$('<li>'+val+'</li>').appendTo('#your_ul_list');

您可以玩这个.

这篇关于jQuery-向列表中添加值-在客户端渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆