javascript shorthand if statement, without the else portion

后端 未结 7 1528
孤街浪徒
孤街浪徒 2020-12-01 07:52

So I\'m using a shorthand javascript if/else statement (I read somewhere they\'re called Ternary statements?)

this.dragHandle.hasClas

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 07:57

    What you have will not work, but why not just use a one line if statement instead.

    if(direction == "right") slideOffset += $(".range-slide").width();

    This involves less typing than the method Ray suggested. Of course his answer is valid if you really want to stick to that format.

提交回复
热议问题