我正在试着学习Jquery。 我有一个问题:我必须动态地发送一个json作为函数的参数。我的代码是这样的:如何将json作为参数传递给函数
$('#grafo').append('<a class="list-group-item graph" href="#" id="' + nome.replace(/ /g,'') + '" onclick="printAnnotation(\'' + json + '\',\'' + index + '\')">' + name + '</a>');
我想获得一个JSON,但结果是一个字符串。
我该如何解决这个问题? PS:对不起,我的英语不好。
不要丢在一个字符串类型。 ''printAnnotation(json,index)“>'会起作用 – hjpotter92
你可以展示更多的代码来显示你定义了'json'和'index'的位置。 –