【发布时间】:2016-04-25 03:01:30
【问题描述】:
我是 Javascript、CSS、HTML 和 jQuery 的新手,遇到了这行使用 condition ? if true : if false 语句的代码,我正在努力理解它。等效的if() {} else {} 语句是什么样的?这是代码行:
$('.app-container').css('background', this.background ? `url(${this.background.get('Href')})` : `url(${DefaultImage.Background}`);
感谢您的任何解释:)
【问题讨论】:
-
不知道你的例子中所有额外的单代码引号是怎么回事:)
-
我只能猜测反引号表示ES6 template strings,否则它们是其他一些未知JS框架的一部分。
标签: javascript jquery css if-statement ternary-operator