亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

對表格進行排序但表格標題已損壞

對表格進行排序但表格標題已損壞

侃侃無極 2022-10-21 09:45:25
我正在為我的 Minecraft 服務器創建一個幫助部分,以便玩家可以查看命令及其用法。我對它們進行了排序,以使其在嘗試查找命令時更有意義。出于某種原因,它通過 Cmds 組織表格,但將表格標題放在底部。我如何讓它跳過這個?由于某種原因,還有一個空白條目。<table id="cmdlist">    <tr>        <th>Command</th>        <th><i style="color: rgb(0,255,255);">Tuple</i> Arguments</th>        <th>Usage</th>        <th>Server(s)</th>        <th>Rank</th>    </tr>    <td>    </td></table><script type="text/javascript">    var Cmds,Args,Usage,Server,Rank;    Cmds = ["/server","/msg","/r","/island,/is","/towny,/t","/nation,/n","/echest","/craft,/wb,/workbench","/tpa","/tpahere","/tpaccept"];    Args = ["(servername)","(playname) (message)","(message)","(optional)","(optional)","(optional)","N/A","N/A","(playername)","(playername)","N/A"]                Usage = ["Used to switch between the hub and gamemodes.",                "Used to send a pm to a player.",                "Sends a pm to the player you last sent/recieved a pm from.",                "Without args opens gui. With args open a specific section.",                "Without args displays town info. With args you can config your town.",                "Without args displays nation info. With args you can config your nation.",                "Open your enderchest via a command.",                "Open a crafting table via a command.",                "Sends a request to teleport to a player.",                "Sends a request to teleport to a player to you.",                "Accepts the last pending teleport request."                ]    }</script> 
查看完整描述

2 回答

?
牛魔王的故事

TA貢獻1830條經驗 獲得超3個贊

table.insertRow(0)會將您的行添加到表格的開頭,將之前的所有行向下推(包括您的表格標題)。你的意思是做,這會在表的末尾table.insertRow(-1)添加一行嗎?


插入行引用


查看完整回答
反對 回復 2022-10-21
?
LEATH

TA貢獻1936條經驗 獲得超7個贊

在您的代碼中,您只對第一列進行排序.. 可以嗎?


   const Cmds = [

       "/server",

       "/msg",

       "/r",

       "/island,/is",

       "/towny,/t",

       "/nation,/n",

       "/echest",

       "/craft,/wb,/workbench",

       "/tpa",

       "/tpahere",

       "/tpaccept"

   ];

   const Args = [

       "(servername)",

       "(playname) (message)",

       "(message)",

       "(optional)",

       "(optional)",

       "(optional)",

       "N/A",

       "N/A",

       "(playername)",

       "(playername)",

       "N/A"

   ];

   const Usage = [

       "Used to switch between the hub and gamemodes.",

       "Used to send a pm to a player.",

       "Sends a pm to the player you last sent/recieved a pm from.",

       "Without args opens gui. With args open a specific section.",

       "Without args displays town info. With args you can config your town.",

       "Without args displays nation info. With args you can config your nation.",

       "Open your enderchest via a command.",

       "Open a crafting table via a command.",

       "Sends a request to teleport to a player.",

       "Sends a request to teleport to a player to you.",

       "Accepts the last pending teleport request."

   ];

   const Server = [

       "*",

       "*",

       "*",

       "Skyblock",

       "Towny",

       "Towny",

       "Towny/Skyblock",

       "Towny/Skyblock",

       "Towny/Skyblock",

       "Towny/Skyblock",

       "Towny/Skyblock"

   ];

   const Rank = [

       "*",

       "*",

       "*",

       "* (Skyblock owner)",

       "* (Town owner)",

       "* (Town owner)",

       "Donator,Donator+,DonatorPro,*Staff",

       "Donator,Donator+,DonatorPro,*Staff",

       "*",

       "*",

       "*"

   ];


   Cmds.sort().reverse();

   var table = document.getElementById("cmdlist");

   for (let i = 0; i < Cmds.length; i++) {

       var row = table.insertRow(i+1);

       [

        Cmds,

        Args,

        Usage,

        Server,

        Rank

      ].forEach((column, index) => {

        row.insertCell(index).innerHTML = column[i]

      })

  }

table, th, td {

  border: 1px dotted #cdcdcd;

}


tr:nth-child(even) {

  background: #eee

}

tr:nth-child(odd) {

  background: #FFF

}


th {

  background-color: #000;

  color: white;

}

<table id="cmdlist">

    <tr>

        <th>Command</th>

        <th><i style="color: rgb(0,255,255);">Tuple</i> Arguments</th>

        <th>Usage</th>

        <th>Server(s)</th>

        <th>Rank</th>

    </tr>

</table>


查看完整回答
反對 回復 2022-10-21
  • 2 回答
  • 0 關注
  • 113 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號