Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    html formatting in javascript

    I have a variable:
    words[1] = "hello sam"

    Is there a way to make it respect html formatting such as..
    words[1] = "<b>hello</b><br><i>sam</i>"

  • #2
    New to the CF scene
    Join Date
    Sep 2008
    Location
    China
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by bvdman89 View Post
    I have a variable:
    words[1] = "hello sam"

    Is there a way to make it respect html formatting such as..
    words[1] = "<b>hello</b><br><i>sam</i>"


    like this :

    words[1].split(' ');
    you can use "split" to split the string to an array,then ,you know

  • #3
    New Coder
    Join Date
    Aug 2008
    Location
    Colfax, California USA
    Posts
    64
    Thanks
    3
    Thanked 5 Times in 5 Posts
    you could use
    Code:
    document.write="<b>hello</b><br><i>sam</i>"
    and put that into a function.

  • #4
    New Coder
    Join Date
    Jan 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the replies.

    I'm very new to javascript. Can you describe "split" more.

    And for document.write, where would I place this?

  • #5
    New to the CF scene
    Join Date
    Sep 2008
    Location
    China
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    split is a function of "String" you can split a string with the function ...
    detail usage you may find in google...so does "document write"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •