Ternary Operator in JavaScript With Multiple Expressions?

后端 未结 6 2030
再見小時候
再見小時候 2021-01-17 14:29
the_styles ? the_styles.appendTo(\'head\'); the_styles=null : the_styles = $(\'.stylesheet\').detach();

Obviously, this isn\'t valid. Notice the \"

6条回答
  •  [愿得一人]
    2021-01-17 14:51

    i agree with glowcoder but if you still want it:

    the_styles ? function(){ the_styles.appendTo('head'); the_styles=null;}() : the_styles = $('.stylesheet').detach();
    

提交回复
热议问题