Is this possible to pass an Object to a javascript when it is created from a string ?
I tried this, but it don't look to work :
var myobject = {name:"auto",color:"blue"};
var btn = "<button type='button' onclick='myfunc(" + myobject + ");'>Edit</button>";
If I inspect the onclick event, the object look like : [object Object]
JSON.stringify()for this. And then, you would need to escape for HTML (or set the attribute value directly). Really though, don't do what you're doing. Add an appropriate event handler and make this much easier on yourself. Also consider usingdata-*attributes if data on the element is more appropriate, and then you can assign a single click handler for all your buttons.