js 行内事件JSON对象传参

<img onclick="getInfo(reData({id:1}))"/>
function reData(data) {
    return typeof JSON.parse(data) == "object" ? data.replace(/"/g, '"') : JSON.stringify(data).replace(/"/g, '"')
}

function getInfo(data){
	var id = JSON.parse(data).id
	...
}

你可能感兴趣的:(JavaScript)