Reputation:
I would like to display my "users email" in plain text within my HTML file.
Right now, my project is constructed of three different files:
index.html - edit.html - my_parse_app.js
In my_parse_app.js I declare all of my javascript / jquery functions to help interact with PARSE.com and my backend. There, I am grabbing the users account information (most importantly, the email).
I do this by using:
var email = currentUser.get("email");
I would like to display the variable "email" in my HTML file. Most important h1 if thats possible, just for practice. Would anyone know how to do this easily using two seperate files? I have tried multiple solutions and none of them seem to work.
Upvotes: 2
Views: 4814
Reputation: 1641
In your HTML file, give the h1
element that will display the email address a unique id
. Then, you can set the innerHTML
property of that element to the value of the email
variable.
HTML:
<h1 id="userEmail">Placeholder</h1>
JS:
var email = currentUser.get("email");
document.getElementById("userEmail").innerHTML = email;
You'll need to make sure that the DOM is ready before you try to get the element by its id
though.
Here's a really simple example: http://jsfiddle.net/jk8yC/
Upvotes: 3