The logged value is shown below:
but why when I use document.write or alert it’s a blank variable.
here’s the code:
$("#subTile").click(function(){
var c=[[],[],[]];//content
$(".col").each(function(){
var r=$(this).attr("rel");
r--;
$(this).find(".bulk").each(function(i){
var t=$(this).find("input:eq(0)").val();//title
var img=$(this).find("input:eq(1)").val();//img url
var content=$(this).find("textarea").val();
if(t!=="")
{
c[r][i]=[];
c[r][i]["title"]=t;
c[r][i]["img"]=img;
c[r][i]["content"]=content;
}
})
});
console.log(c);
document.write(c);
because document.write is converting c into its string representation.
you can use: