Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <table>
  <tbody>
    <tr>
      <th>チーム名</th>
      <th>チームA</th>
      <th>チームB</th>
      <th>チームC</th>
      <th>チームD</th>
      <th>チームE</th>
      <th>チームF</th>
      <th>勝</th>
      <th>負</th>
      <th>分</th>
      <th>勝点</th>
      <th>得失点</th>
      <th>順位</th>
    </tr>
    <tr>
      <th>チームA</th>
      <td style="background-color:#999;"></td>
      <td>○ 3 - 2</td>
      <td>○ 5 - 2</td>
      <td>× 4 - 6</td>
      <td>○ 4 - 1</td>
      <td>○ 4 - 1</td>
      <td>4</td>
      <td>1</td>
      <td>0</td>
      <td class="win">12</td>
      <td class="diff">8</td>
      <td class="rank"></td>
    </tr>
    <tr>
      <th>チームB</th>
      <td>× 2 - 3</td>
      <td style="background-color:#999;"></td>
      <td>× 2 - 4</td>
      <td>× 2 - 3</td>
      <td>× 0 - 1</td>
      <td>× 0 - 1</td>
      <td>0</td>
      <td>5</td>
      <td>0</td>
      <td class="win">0</td>
      <td class="diff">-6</td>
      <td class="rank"></td>
    </tr>
    <tr>
      <th>チームC</th>
      <td>× 2 - 5</td>
      <td>○ 4 - 2</td>
      <td style="background-color:#999;"></td>
      <td>○ 6 - 5</td>
      <td>○ 5 - 1</td>
      <td>○ 5 - 1</td>
      <td>4</td>
      <td>1</td>
      <td>0</td>
      <td class="win">12</td>
      <td class="diff">8</td>
      <td class="rank"></td>
    </tr>
    <tr>
      <th>チームD</th>
      <td>○ 6 - 4</td>
      <td>○ 3 - 2</td>
      <td>× 5 - 6</td>
      <td style="background-color:#999;"></td>
      <td>○ 8 - 0</td>
      <td>○ 8 - 0</td>
      <td>4</td>
      <td>1</td>
      <td>0</td>
      <td class="win">12</td>
      <td class="diff">18</td>
      <td class="rank"></td>
    </tr>
    <tr>
      <th>チームE</th>
      <td>× 1 - 4</td>
      <td>○ 1 - 0</td>
      <td>× 1 - 5</td>
      <td>× 0 - 8</td>
      <td style="background-color:#999;"></td>
      <td>△ 1 - 1</td>
      <td>1</td>
      <td>3</td>
      <td>1</td>
      <td class="win">4</td>
      <td class="diff">-14</td>
      <td class="rank"></td>
    </tr>
    <tr>
      <th>チームF</th>
      <td>× 1 - 4</td>
      <td>○ 1 - 0</td>
      <td>× 1 - 5</td>
      <td>× 0 - 8</td>
      <td>△ 1 - 1</td>
      <td style="background-color:#999;"></td>
      <td>1</td>
      <td>3</td>
      <td>1</td>
      <td class="win">4</td>
      <td class="diff">-14</td>
      <td class="rank"></td>
    </tr>
  </tbody>
</table>

              
            
!

CSS

              
                body
  padding 1rem
table
  display block
  white-space nowrap

tbody
  display table
  width 100%
  border 1px solid #666
  border-collapse collapse
  text-align center

th, td
  padding .5em
  border 1px solid #666

              
            
!

JS

              
                const wins = document.querySelectorAll('.win')
const makeData = () => {
  const data = []
  Array.from(wins).forEach((e, i) => {
    const teamData = {}
    teamData.team = i
    teamData.win = e.innerText
    teamData.diff = e.nextElementSibling.innerText
    teamData.rank = 0
    data.push(teamData)
  })
  return data
}
const data = makeData()

const ranking = (arr) => {
  const map = arr.map((x, y, z) => {
    let plus = 1
    let filter = z.filter((w) => {
      if (Number(w['win']) === Number(x['win'])) {
        if (Number(w['diff']) > Number(x['diff'])) {
          plus++
        }
      }
      else if (Number(w['win']) > Number(x['win'])) {
        return true
      }
    }).length
    filter += plus
    return filter
  })
  return map
}
const rank = ranking(data)

const ranks = document.querySelectorAll('.rank')
Array.from(ranks).forEach((e, i) => {
  e.innerHTML = rank[i]
})

              
            
!
999px

Console