1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What is the meaning of the colon (:) and question mark (?) in jquery?

Discussion in 'jQuery' started by learnwebsitedesigncom, Oct 20, 2011.

  1. #1
    Hi everyone, can the someone tell me what the meaning of the colon :)) and the question mark (?) is in the following line of code?

    var $next =  $active.next().length ? $active.next()
            : $('#slideshow IMG:first');[CODE]
    Code (markup):
    [/CODE]

    I got the code from this tutorial: http://jonraasch.com/blog/a-simple-jquery-slideshow

    Thanks
     
    learnwebsitedesigncom, Oct 20, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    That's an inline if:

    If true, do the thing before the question mark, otherwise do the thing after the colon. IOW, if $active.next() has a length (is not 0) $next = $active.next(), else $next = $('#slideshow IMG:first'). It's JS, not jQuery. (Only the $('#slideshow IMG:first') part is jQuery.) The syntax (aside from the jQuery part) is the same in PHP.
     
    Rukbat, Oct 21, 2011 IP
  3. learnwebsitedesigncom

    learnwebsitedesigncom Active Member

    Messages:
    264
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thank you very much.
     
    learnwebsitedesigncom, Oct 23, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Slight edit (what I said is actually pretty stupid):

    If true, do the thing after the question mark, otherwise do the thing after the colon. The thing before the question mark is what you're testing.
     
    Rukbat, Oct 24, 2011 IP
  5. learnwebsitedesigncom

    learnwebsitedesigncom Active Member

    Messages:
    264
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #5
    I thought that was what you meant. I vaguely remember seeing this in a tutorial some time ago. Can you point me to one or more tutorials on this?

    again Thank You
     
    learnwebsitedesigncom, Oct 27, 2011 IP
  6. Abitha

    Abitha Member

    Messages:
    141
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    36
    #6
    Abitha, Nov 5, 2011 IP
  7. easyolcash

    easyolcash Active Member

    Messages:
    302
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    80
    Digital Goods:
    1
    #7
    if $active.next().length is true, execute $active.next() else execute $('#slideshow IMG:first')
     
    easyolcash, Sep 28, 2013 IP
  8. HussainMHB

    HussainMHB Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #8
    I'd recommend w3schools...
     
    HussainMHB, Oct 26, 2013 IP