127
rated 0 times
[
128]
[
1]
/ answers: 1 / hits: 59060
/ 10 Years ago, sun, april 13, 2014, 12:00:00
In my js function,I create a div and a link
,when click the link,I will pass a parameter the another js funcion?What's wrong with my code?
js function1
//pass a json:the browser show wrong:SyntaxError: missing ] after element list
//passJson([object Object])
var dataItem=getDataItem();//a json object which has title and name property
var divStr=<div><a style='cursor: pointer' onclick='passJson( + dataItem +)'><span title='spantitle'><i class='icon-mouse'></i></span></a>;</div>;
So I try to add the [] to the function,but it still show wrong.
js function2
//pass a json:the browser show wrong:SyntaxError: missing ] after element list
//passJson([object Object])
var dataItem=getDataItem();// a json object which has title and name property
var divStr=<div><a style='cursor: pointer' onclick='passJson([ + dataItem +])'><span title='spantitle' ><i class='icon-mouse'></i></span></a>;</div>;
More From » jquery