2012-10-18 62 views
0

下面是我的HTML代碼刪除表,我需要你的幫助來解決2個問題,渲染嵌套UL LI使用模板和代碼

  1. 我需要從代碼中刪除一個table並使其無表格。
  2. 使用模板呈現此代碼的最佳方式& jQuery AJAX,這裏的數據來自XML文件。

運行代碼:http://jsfiddle.net/samansari/ppu6T/

XML數據:

$(function() { 
    $.ajax({ 
     type: "POST", 
     url: "/echo/xml/", 
     dataType: "xml", 
     data: { 
      xml: "<data caption='Start Processes'><heading caption='Customer Registration'><info caption='Credit note approval' desc='Credit Note request form and approval process.'/></heading><heading caption='Installation'><info caption='Credit note approval' desc='Credit Note request form and approval process..'/><info caption='Credit And Rebill Note (smartforms)' desc='Generate and Process a Letter of Guarantee for the customer.'/></heading></data>>" 
     }, 
     success: function(xml) { 
      console.log(xml); 
     } 
    }); 
});​ 

HTML代碼:

<div id="navcontainer"> 
    <ul> 
     <li> 
      <div class="gtpointer"><span>&#160;&#160;&#160;&#160;Start Processes</span> </div>   
      <ul> 
       <li> 
        <span> <span class="gtpointer">Customer Registration</span> </span> 
        <ul> 
         <li> 
          <span> 
           <table width="100%" border="0"> 
            <tr> 
             <td width="30%"> 
              <span class="landingSubmenu"><a href="#">Credit note approval</a></span> 
             </td> 
             <td> 
              <span >Credit Note request form and approval process.</span> 
             </td> 
            </tr> 
           </table> 
          </span> 
         </li> 
        </ul> 
       </li> 

       <li> 
        <span> <span class="gtpointer">Installation</span> </span> 
        <ul> 
         <li> 
          <span> 
           <table width="100%" border="0"> 
            <tr> 
             <td width="30%"> 
              <span class="landingSubmenu"><a href="#">Credit note approval</a></span> 
             </td> 
             <td> 
              <span >Credit Note request form and approval process.</span> 
             </td> 
            </tr> 
           </table> 
          </span> 
         </li> 
         <li> 

          <span> 
           <table width="100%" border="0"> 
            <tr> 
             <td width="30%"> 
              <span class="landingSubmenu"><a href="#">Credit And Rebill Note (smartforms)</a></span> 
             </td> 
             <td> 
              <span >Generate and Process a Letter of Guarantee for the customer.</span> 
             </td> 
            </tr> 
           </table> 
          </span> 

         </li> 
        </ul> 
       </li> 


      </ul> 
     </li> 



    </ul> 
</div> 

感謝所有。

回答

0

對於第一個問題: 只是使用內聯塊顯示DIV而不是TD,並刪除TABLE和TR。 然後設置爲兩者的DIV寬度的百分比,和垂直取向到中間模擬陣:

http://jsfiddle.net/bQbzK/

HTML

<div id="navcontainer"> 
    <ul> 
     <li> 
      <div class="gtpointer"> 
       <span>&#160;&#160;&#160;&#160;Start Processes</span> 
      </div>   
      <ul> 
       <li> 
        <span> 
         <span class="gtpointer">Customer Registration</span> 
        </span> 
        <ul> 
         <li> 
          <span> 
           <div class="col1"> 
            <span class="landingSubmenu"> 
             <a href="#">Credit note approval</a> 
            </span> 
           </div> 
           <div class="col2"> 
             <span > 
             Credit Note request form and approval process. 
             </span> 
           </div> 
          </span> 
          </li> 
        </ul> 
       </li>      
       <li> 
        <span> 
         <span class="gtpointer">Installation</span> 
        </span> 
        <ul> 
         <li> 
          <span> 
           <div class="col1"> 
            <span class="landingSubmenu"> 
             <a href="#">Credit note approval</a> 
            </span> 
           </div> 
           <div class="col2"> 
            <span > 
            Credit Note request form and approval process. 
            </span> 
           </div> 
          </span> 
          </li> 
          <li>          
           <span> 
           <div class="col1"> 
            <span class="landingSubmenu"> 
             <a href="#"> 
             Credit And Rebill Note (smartforms) 
             </a> 
            </span> 
           </div> 
           <div class="col2"> 
            <span> 
            Generate and Process a Letter of 
            Guarantee for the customer. 
            </span> 
           </div> 
           </span>  
          </li> 
         </ul> 
        </li> 
        </ul> 
       </li>  
      </ul> 
     </div> 

CSS:

div{ 
    display: inline-block; 
    vertical-align: middle; 
} 
.col1{ 
    width: 30%; 
} 
.col2{ 
    width: 69%; 
}