怎么给JQ生成的元素绑定动作?使用document.ready不行

我的思路是,想使用JQ生成了一个id="test"的元素,然后在用
$document().ready(function(){$("#test").click()})
的方法来绑定动作,但是不行,貌似document.ready,刷新一次才能绑定,但jq生成新的元素因为没有刷新,所以无法绑定?

有什么办法可以做到这个吗?我现在能想是生成test元素的时候,绑定一个onclick动作,但是这样子就是js了,代码要重新写了。。有啥JQ的方法吗?

http://www.jquery001.com/jquery-on.html

$("#test").click(function(){

})

$("#test").on("click",function(){

})

你在生成 id 元素后再进行绑定试试!

用jquery的事件委托试下,假设query生成的元素id为test

 $('document').on('click','#test',function(){
        alert('我是回调函数');
 });
 <!DOCTYPE html>
<html>
<head>
<script src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js">
</script>
<script>
$(document).ready(function(){
   var a = 1,
    $_div = $('#test');
    $('input[name=addbtn]').on('click', function () {
        $_div.append('<input type="button" name="test' + a + '" value="按钮' + a + '"/>');
        a++;
    });

    //偶数项点击事件
    $_div.on('click', 'input[name^=test]:even', function () {   
        alert('我是有效的on方法,你能看见我吗:' + this.value);
    });

    //奇数项绑定的点击事件  发现点击无效,而是用live方法却能够支持
    $('input[name^=test]:odd').on('click', function () {   
        alert('我是无效的on方法,你不能看见我');
    });

    //奇数项绑定的点击事件  发现点击无效,而是用live方法却能够支持
    $('input[name^=test]:odd').live('click', function () {
        alert('我是live方法,你能看见我吗:' + this.value);
    });
});
</script>
</head>
<body>
<input type="button" name="addbtn" value="按钮添加" />
<div id="test"></div>
</body>
</html>

打错了,document的引号去掉

我觉得可能是元素没生成,你就要绑定id。