JSFiddle - React, Tailwind, and code Playground

by whoamiwho

CSS

#foo { width: 200px; height: 120px; background: yellow }

JavaScript

//pass a json:the browser show wrong:SyntaxError: missing ] after element list
 //recordQuery([object Object])


function passJson(obj) {
 // obj= JSON.parse(obj);
   // alert(obj);
    alert(obj.title+obj.name);
    console.log(obj);
}

var dataItem={ title: "hello", name: "snoopy" }; //a json object which has title and name property
//dataItem = JSON.stringify(dataItem);
var divStr="<div id='foo'><a style='cursor: pointer'  onclick='passJson(dataItem)'><span title='spantitle'><i class='icon-mouse'></i>hmmm</span></a>;</div>";
  
$("body").append(divStr);