我的问题是我正在使用的 CMS 在单个跨度元素中输出日期,如下所示:M/d/Y,它输出以下 html:Mar/03/14。
我想设置日期样式以叠加到每个变量上 例如2014(底部)、JAN(年上)和 14(月上)。
不幸的是,我只能访问 css 和 smarty tpl 文件,不能访问 php 文件。我正在寻找 CSS 解决方案,但我也对 JS 持开放态度。
任何建议表示赞赏。
最佳答案
我用 jQuery 写了这个例子:
$(document).ready(function(){
// You can change for your classes or add this in your smarty template
var month = $('.month'),
day = $('.day'),
year = $('.year'),
out = $('.out');
var months = {
'JAN': '01'
'FEB', '02',
'MAR': '03'
// etc...
};
// Hides the unecessary elements
month.hide();
year.hide();
day.hide();
out.html(months[month.text()] + '/' + day.text() + '/' + year.text());
});
关于php - 如何设置由 php 创建的日期并在单个 span 元素中输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22817549/