var food = {} $("button").click(function(){ food={} $("span").text("") $("#mytable tbody tr").each(function(){ var key = $(this).children("td").eq(0).text() var value = $(this).find("input").val() food[key]=value }) for(key in food){ $("span").append(key+":"+food[key]+"||") } })