Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript JQuery Variables

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #29180
    lyleyboy
    Member

    Hi all,

    I’m struggling with something that is probably very simple.

    In php if I have a variable I can add to it easily like

    Code:
    $say = “hello”;
    $say.=” world”;

    And now $say will read "hello world"

    How on earth can I do that in JQuery?

    Thanks all.

    #76640
    lyleyboy
    Member

    Ok so I found it. I looked for ages and then came accross the answer.

    Code:
    var say = “Hello”;

    say =+ ” World”;

    I hope this helps someone else.

    #76641
    Rob MacKay
    Participant

    haha I just posted that :D

    #76644
    lyleyboy
    Member

    I can’t believe I was so daft. Nevermind.

    Thanks anyway… :D

    #76661
    Rob MacKay
    Participant

    well if I use PHP too much I can never remember what the concatenation is in Javascript lol

    #76702
    Chris Coyier
    Keymaster

    For the record, jQuery has nothing to do with that, it’s just JavaScript, and the syntax is:

    Code:
    var someString = “Hello, “;
    someString += “World!”;
    #76713
    lyleyboy
    Member

    Thanks for the Chris. When I asked I didn’t know if JQuery did it a specific way.
    I’m not expert with JavaScript or JQuery to be honest.

    Thanks for the help in any case.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.