第二周第二天

任務(wù):

1,繼續(xù)優(yōu)化經(jīng)驗分享詳細(xì)頁面HTML
2,后臺代碼編寫,提取 經(jīng)驗的相關(guān)信息

===================================

問題一: 給DIV設(shè)置了滾動條,但AJAX提取數(shù)據(jù)寫入這個div,滾動條失效。(ajax取的是個table)

效果如下:


沒有滾動條

解決辦法:
用javascript賦予CSS值就好了。

$('#Exper_right_col').css("overflow", "auto");
$('#Exper_right_col').css("height", $("#Exper_right_col").outerHeight());
$('#Exper_right_col').css("width", $("#Exper_right_col").outerWidth());

CSS里怎么設(shè)置都沒用。。。js設(shè)置就好了。。怪事?。?!

問題二 : /Date(1463629837000)/ 如何用javascript轉(zhuǎn)換成日期?

/Date(1463629837000)/ 是oracle數(shù)據(jù)庫里取出,然后轉(zhuǎn)換成json輸送到前端。

解決方法:

<script>
var s ="/Date(1463629837000)/";
s=s.replace(/[^0-9]/ig,"");//先把里面的數(shù)字取出來
alert(s);
var date=new Date(parseInt(s)+0800);//1463629837000是一個毫秒級的timespan,+8是時區(qū)
Date.prototype.format = function(format){ 
            var o = { 
            "M+" : this.getMonth()+1, //month 
            "d+" : this.getDate(), //day 
            "h+" : this.getHours(), //hour 
            "m+" : this.getMinutes(), //minute 
            "s+" : this.getSeconds(), //second 
            "q+" : Math.floor((this.getMonth()+3)/3), //quarter 
            "S" : this.getMilliseconds() //millisecond 
            } 
  
            if(/(y+)/.test(format)) { 
            format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
            } 
  
            for(var k in o) { 
            if(new RegExp("("+ k +")").test(format)) { 
            format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); 
            } 
            } 
            return format; 
        } 
        
        document.write(date.format("yyyy-MM-dd hh:mm:ss"));
</script>

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容