jquery Using ranges in switch cases?

后端 未结 4 823

Switch cases are usually like

Monday: 
Tuesday: 
Wednesday: 
etc. 

I would like to use ranges.

from 1-12: 
from 13-19:
fr         


        
4条回答
  •  春和景丽
    2021-01-05 17:20

    You can make interesting kludges. For example, to test a number against a range using a JavaScript switch, a custom function can be written. Basically have the function test a give n value and return it if it's in range. Otherwise returned undefined or some other dummy value.

    
    

    This works in Google Chrome. I didn't test other browsers.

提交回复
热议问题