วิธีรับเนื้อหาข้อความของ :: ก่อนองค์ประกอบหลอก [ทำซ้ำ]

ในตัวอย่างนี้เนื้อหาของ ::before องค์ประกอบหลอกไม่ใช่ค่าคงที่ แต่เป็นตัวนับ ฉันต้องการรับค่าปัจจุบัน "2" แทนที่จะเป็นสูตรทั่วไป "counter(itemcounter)"

// Expected value is 2 instead of counter(itemcounter).
alert(window.getComputedStyle(document.querySelector('li:nth-child(2)'), '::before').getPropertyValue('content'));
ul {
  counter-reset: itemcounter;
  list-style-type: none;
}
li {
  line-height: 20px;
  margin-bottom: 10px
}
li::before {
  background: #000;
  border-radius: 10px;
  color: #fff;
  counter-increment: itemcounter;
  content: counter(itemcounter);
  display: block;
  float: left;
  font-family: sans-serif;
  font-weight: 700;
  font-size: 14px;
  height: 20px;
  line-height: 20px;
  margin-right: 5px;
  text-align: center;
  width: 20px;
}
<ul>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ul>


person Tamás Bolvári    schedule 10.10.2015    source แหล่งที่มา
comment
ฉันจะทำเครื่องหมายว่าซ้ำกัน ขอบคุณ   -  person Tamás Bolvári    schedule 11.10.2015