chrome和firefox可以显示为<p><span>xxxx</span></p>
,但IE11显示为<p></p>
时使用'slice'来剪切HTMLObject数组,如何获得答案?
的javascript:
var wrap = document.querySelector('.wrap');
var select = document.querySelector('.select');
var marks = Array.prototype.slice.call(wrap.querySelectorAll('p'));
var impression_num = document.querySelector('#impression_num');
impression_num.textContent = marks.length;
wrap.innerHTML = ''; // I think problem start here
var ul = document.createElement('ul');
var start = 0;
var length = 20;
var num = Math.ceil(marks.length / 20);
var selectData = marks.slice(start, length);
console.log(selectData[0].outerHTML); // show <p></p> not <p><span>xxxx</span></p>
HTML:
<section class="wrap">
<p><span>xxxx</span></p>
<p>xxxx<span id="impression_num"></span>xxxx</p>
<p class="impression" style="font-size:22px;" ><a href="#">xxxx</a></p>
<p class="impression">xxxx</p>
<p class="impression">xxxx</p>
<p class="impression">xxxx</p>
<selection>