这是我想要实现的目标 -
$(document).ready(function() {
function t() {
var t = this,
a = moment,
e = $(".scheduleTimeZone option:selected"),
d = $("[data-current-timezone]", t),
m = $("[data-start-date]", t),
n = $("[data-start-time]", t),
o = $("[data-end-date]", t),
r = $("[data-end-time]", t),
i = d.data("currenttimezone"),
c = e.val(),
h = "MMMM DD, YYYY",
f = "hh:mm A",
u = h + " " + f,
l = m.data("start-date") + " " + n.data("start-time"),
s = a.tz(l, u, i).utc().format(),
z = a(s).tz(c),
M = o.data("end-date") + " " + r.data("end-time"),
Y = a.tz(M, u, i).utc().format(),
p = a(Y).tz(c);
m.html(z.format(h)), n.html(z.format(f)), o.html(p.format(h)), r.html(p.format(f))
}
$(".scheduleTimeZone").change(function() {
$(".profile-stat[data-datetime]").each(t)
})
});
document.w; //这样的东西也不起作用 document.w("东西&#34); //这太不行了
为什么这不起作用?我一直在寻找一种方法来实现这样的目标。引用函数的方法? 我有工作JS代码,但为了缩小我想要这样做。
更新 原始代码
缩小工作量
$(document).ready(function() {
function t() {
var t = this,
a = moment,
mf = format,
e = $(".scheduleTimeZone option:selected"),
d = $("[data-current-timezone]", t),
m = $("[data-start-date]", t),
n = $("[data-start-time]", t),
o = $("[data-end-date]", t),
r = $("[data-end-time]", t),
i = d.data("currenttimezone"),
c = e.val(),
h = "MMMM DD, YYYY",
f = "hh:mm A",
u = h + " " + f,
l = m.data("start-date") + " " + n.data("start-time"),
s = a.tz(l, u, i).utc().af(),
z = a(s).tz(c),
M = o.data("end-date") + " " + r.data("end-time"),
Y = a.tz(M, u, i).utc().af(),
p = a(Y).tz(c);
m.html(z.af(h)), n.html(z.af(f)), o.html(p.af(h)), r.html(p.format(f))
}
$(".scheduleTimeZone").change(function() {
$(".profile-stat[data-datetime]").each(t)
})
});
我想用mf替换格式
{{1}}
我怎样才能跳过重复?