Reputation: 673
i have a java-script code which print the post to fb wall
link and call a PostToWall
Javascript function on click, in this function i am trying to read data under span
by its id. But unfortunately its not returning the span data
.Please help me to solve my problem.
First: this code prints on my html page after a certain JS function is called
$('#content').html('<h1>You\'re done</h1><br/><a href="#" onclick="return postToWall();"> Share your score in FACEBOOK</a>\n
Second: Users click on the "Share your ...FB" then it calls this function:
function postToWall() {
var msg = document.getElementById("timespent"); alert(msg);
------
}
It is callin func but its not showing the data under under span id=timespent
where <span id="timespent" style="zoom: 80%" class="timeisplay">4732</span>
Upvotes: 1
Views: 92
Reputation: 148110
You have put the timespent
span object in alert instead of its html. You need to using innerHTML
to show the html with span
alert(msg.innerHTML);
Upvotes: 1