AJAX动态读取的数据怎么获取值

AJAX动态读取的数据如何获取值
ajax获取了data 用each将数据添加到BODY上,数据格式为

<span id="span1">商品id</span> <input tpye="text" id="msg"/> <input tpye="button" id="update" class="up"/>


我想实现的是:点击按钮,将textbox的值 添加到 该商品id的 数据库信息中

问题1:怎么获取到动态生成的span input的值?

问题2:按钮怎么绑定事件?
我懂用live来绑定,可是我不懂怎么区别 这个按钮是属于哪个商品ID的按钮?然后如何把获取对应的ID的值。

求大神代码说明,我新手,给我思路我不会写...我已经问了3次了,这问题,都没有热心人说个详细代码

------解决方案--------------------

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>无标题文档</title>
<script src="jquery-1.10.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(document).on("click", "input.up", function () {
            alert($(this).prev().prev().text());
        });
    });
</script>
</head>
 
<body>
<form id="zhuce" action="#" method="post">
    <table>
        <tbody>
            <tr>
                <td>
                    <span id="span1">商品id1</span> <input type="text" id="msg"/> <input type="button" id="update" class="up"/>
                </td>
            </tr>
            <tr>
                <td>
                    <span id="span2">商品id2</span> <input type="text" id="Text1"/> <input type="button" id="Text2" class="up"/>
                </td>
            </tr>
        </tbody>
    </table>
</form>
</body>
</html>