第十三天 評(píng)論

1. css樣式嵌套

css代碼:

  .comm{
    padding:10px;
    margin:2px;
    
    border:1px solid #ccc;
  }

html 代碼:

  <div class="comm">
    這是一樓的內(nèi)容
    <div class="comm">
      這是二樓的內(nèi)容
      <div class="comm">
        這是三樓的內(nèi)容
      </div>
    </div>
  </div>

2. 數(shù)據(jù)存儲(chǔ)結(jié)構(gòu)

評(píng)論和回復(fù)數(shù)據(jù)結(jié)構(gòu)

  {
      _gid://商品ID
      _uid:ObjctID(),//用戶ID
      _username:,//用戶名
      _content://評(píng)論內(nèi)容
      _createtime://評(píng)論時(shí)間
      _status://狀態(tài)
      _reply:[//回復(fù)評(píng)論
        {
          _id:ObjectID(),//回復(fù)自動(dòng)ID
          _uid:ObjctID(),//用戶ID
          _username:,//用戶名
          _content://回復(fù)內(nèi)容
          _createtime://回復(fù)時(shí)間
        },
        ...
      ]
    }
  

遞歸格式化

      //遞歸格式化
      function formatReply(reply, id, j){
        var html = '';
        html += '<div class="ext-discuss-div">';
        html += '<p class="ext-user"><span style="float: left;">'+(reply[j]._username)+'</span><span style="float: right;">'+(reply[j]._createtime)+'</span><div style="clear:both"></div></p>';
        html += '<p class="ext-content">'+(reply[j]._content)+'</p>';
        html += '<p class="ext-dis-btn" ><button class="ui-btn ui-btn-inline ext-ui-btn" data-disid="'+(id)+'" onclick="showPanelForReply(this)">回復(fù)</button></p>';
          
        if(j < reply.length - 1){
          html += formatReply(reply, id, j+1);
          
        }
        
        html += '</div>';
        
        return html;
      }

測(cè)試

var test = [{_username:'aaa',_content:'cont_aaa',_createtime:'20160506'},{_username:'aaa',_content:'cont_aaa',_createtime:'20160506'}];

var res = formatReply(test, '99', 0);

console.log(res);

3. jquery 序列化表單

html 代碼:

  <form id="myForm">
    <input type="text" name="username"/>
    <input type="text" name="password"/>
  </form>

jquery 代碼:


  $("#myForm").serialize();

結(jié)果

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

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

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