The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

How to add a class to this javascript code?

View previous topic View next topic Go down

Solved How to add a class to this javascript code?

Post by Starrain on Sun 17 Jan - 12:40

Hello! ^^
I have just found this topic and this code:
Code:
<script type="text/javascript">document.write(_userdata.avatar)</script>
I'd like to put this into a html page, but I was wondering if there is any possibility to give this code a class so that I can add CSS codes to it. I haven't had the chance to learn javascript yet, so it would be nice if someone could tell me how to add a class to the code ^^

Greetings, Starrain





Last edited by Starrain on Tue 19 Jan - 20:10; edited 1 time in total
avatar
Starrain
New Member

Female Posts : 5
Reputation : 1
Language : Html | CSS

http://highschoolofmagic.forumieren.com/

Back to top Go down

Solved Re: How to add a class to this javascript code?

Post by Ange Tuteur on Mon 18 Jan - 17:05

Hi @Starrain,

document.write() can take any string of HTML and will parse it at run time. In answer to your question, you can concat the avatar variable between two HTML strings.
Code:
<script type="text/javascript">document.write('<span class="user_avatar">' + _userdata.avatar + '</span>')</script>

If any questions let me know. Wink
avatar
Ange Tuteur
Forumaster

Male Posts : 13181
Reputation : 2889
Language : EN10, FR5
Location : Macungie, PA

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: How to add a class to this javascript code?

Post by Starrain on Tue 19 Jan - 20:09

It works! Thank you very much and have a nice day ^-^
avatar
Starrain
New Member

Female Posts : 5
Reputation : 1
Language : Html | CSS

http://highschoolofmagic.forumieren.com/

Back to top Go down

Solved Re: How to add a class to this javascript code?

Post by Ange Tuteur on Tue 19 Jan - 20:50

You're welcome ^^

Topic archived

Have a good day. Smile
avatar
Ange Tuteur
Forumaster

Male Posts : 13181
Reputation : 2889
Language : EN10, FR5
Location : Macungie, PA

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum