jquery - print javascript array in html -
not sure how print results onto html. can through alerts. how print on browser?
<!doctype html> <html> <body> <script> var parsed = ""; var myobject = [{ firstname: "jane", lastname: "doe", email: "jdoe@email.com" }, { firstname: "ja", lastname: "joe", email: "je@email.com" }, { firstname: "janet", lastname: "joes", email: "jsse@email.com" }]; (i = 0; < myobject.length; i++) { var myobj = myobject[i]; (var property in myobj) { parsed += property + ": " + myobj[property] + "\n"; alert(property); alert(myobj[property]); } } alert(parsed); </script> </body> </html>
not sure how print results onto html. can through alerts. how can print on browser?
<!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> <textarea id="display" style="width:1000px;height:1000px"></textarea> <script> var parsed = ""; var myobject = [{ firstname: "jane", lastname: "doe", email: "jdoe@email.com" }, { firstname: "ja", lastname: "joe", email: "je@email.com" }, { firstname: "janet", lastname: "joes", email: "jsse@email.com" }]; (i = 0; i< myobject.length; i++) { var myobj= myobject[i]; (var property in myobj) { parsed += property + ": " + myobj[property] + "\n"; } } $("#display").val(parsed); </script> </body> </html>
Comments
Post a Comment