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.

else if with no else?

Discussion in 'JavaScript' started by pr0xy122, Jul 6, 2012.

  1. #1
    Can someone tell me if these is valid, essentially I want the script to 'do nothing' if these two conditions are not met?

    Do I need the 'else' that should usually follow?

    					if(detector.width()<=420 && detector.width()>300) {
    														
    					}
    					else if(detector.width()<=300) {
    					
    					}
    Code (markup):
    Thanks!
     
    pr0xy122, Jul 6, 2012 IP
  2. igunz

    igunz Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    no. you dont need the 'else'. the script run from top. first check is the first if condition met. if met do in the bracket. if not. check the second if. if the condition meet do in the bracket. if no condition met. the script will do nothing.
     
    igunz, Jul 10, 2012 IP
  3. Irfi0009

    Irfi0009 Banned

    Messages:
    17,584
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    48
    #3
    not you dont need the else the script run from top first of all check
     
    Irfi0009, Jul 11, 2012 IP