How to add text to an HTML using JavaScript

For developers using the Construct 2 Javascript SDK

Post » Sun Nov 09, 2014 8:37 pm

Here's the problem:
I want to add a text to an a paragraph element with id "text".
How Can I obtain that from JavaScript, all I get is nothing :(
ImageImageImageImageImage
B
56
S
15
G
5
Posts: 852
Reputation: 11,446

Post » Mon Nov 10, 2014 4:53 am

Use ajax that will help I feel.
Image
B
53
S
12
G
2
Posts: 259
Reputation: 5,041

Post » Mon Nov 10, 2014 8:41 pm

socialpilgrim wrote:Use ajax that will help I feel.

Thank you! I figured out from the internet by the way :lol:
the code was:
Code: Select all
var addMessage = function() {
       document.getElementById("text").innerHTML = "thanks for submitting this message!";
};
ImageImageImageImageImage
B
56
S
15
G
5
Posts: 852
Reputation: 11,446

Post » Tue Nov 11, 2014 9:41 am

or quicker solution :
Code: Select all
$.("#element").html("thanks for submitting this message!");
Passionate developer

If my work helped you to make your project, please consider making a donation :)
B
44
S
12
G
14
Posts: 631
Reputation: 10,987

Post » Tue Nov 11, 2014 8:13 pm

septeven wrote:or quicker solution :
Code: Select all
$.("#element").html("thanks for submitting this message!");

Thanks for the better solution ! :D but I want to ask, what does the dollar sign means? and thanks in advance
ImageImageImageImageImage
B
56
S
15
G
5
Posts: 852
Reputation: 11,446

Post » Wed Nov 12, 2014 12:22 am

go to http:(erase the space)//www.w3schools.com/
B
9
S
3
G
1
Posts: 128
Reputation: 1,116


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest