如何从已注册事件发送JavaScript对象?

如何从已注册事件发送JavaScript对象?,javascript,jquery,html,javascript-objects,Javascript,Jquery,Html,Javascript Objects,我无法将对象从已注册事件发送到JavaScript函数。下面是更改代码的复选框;在test()函数中图是对象: $('#tblEntity').append('<tr><td><input type="checkbox" checked="checked" onchange=test("' + figure + '","' + id + '") /></t

我无法将对象从已注册事件发送到JavaScript函数。下面是更改代码的复选框;在
test()
函数中
对象

$('#tblEntity').append('<tr><td><input type="checkbox" 
                checked="checked" 
                onchange=test("' + figure + '","' + id + '")
                /></td><td>' + Column.figure.text + '</td></tr>');
当我在IDE的运行时视图中看到注册的函数时,它的格式不正确:

function onchange(event){
    test([object
}

您可以在这里查看我的示例:

您正在将对象转换为字符串。因此,对象的字符串版本为:“[object]”。您应该传递一个包含对象和id的回调函数

// This is what you will put into the onChange
// event. It wraps 'figure' and 'id'. It's
// a function callback !
var callbackTest = function(){
     test(figure, id);   
}

// Your input checkbox
// Declared in jQuery but this is
// optional
var input = $("<input>")
    .attr("type", "checkbox")
    .attr("checked", "checked")
    .on("change", callbackTest)
//这是您将在onChange中输入的内容
//事件。它包装了“figure”和“id”。它是
//函数回调!
var callbackTest=函数(){
试验(图,id);
}
//您的输入复选框
//在jQuery中声明,但这是
//可选的
变量输入=$(“”)
.attr(“类型”、“复选框”)
.attr(“已检查”、“已检查”)
.on(“更改”,回拨测试)

请提供一个JSFIDLE,以便我们能更好地帮助您。@如果您要费心编辑,请不要留下残缺的英文。@tchrist ty为正确答案,我明白了it@tchrist:大写字母之王?:D)第(1)款每件事都很好,但设计并不像预期的那样。内部html是“EmpID”
// This is what you will put into the onChange
// event. It wraps 'figure' and 'id'. It's
// a function callback !
var callbackTest = function(){
     test(figure, id);   
}

// Your input checkbox
// Declared in jQuery but this is
// optional
var input = $("<input>")
    .attr("type", "checkbox")
    .attr("checked", "checked")
    .on("change", callbackTest)