知识点:cloneNode()方法。
锚点:无缝轮播时,深度克隆第一项放到最后
function clone() {
const first = ul.children[0];
const newLi = first.cloneNode(true);
ul.appendChild(newLi);
}
clone();
要点:括号内为可选项,决定是否采用深度克隆。如果为 true,则该节点的所有后代节点也都会被克隆,如果为 false,则只克隆该节点本身。
锚点:今日头条搜索框背景颜色切换。
input.addEventListener('input', function () {
input.style.background = 'white';
if (input.value === '') {
input.style.background = 'transparent';
}
})
要点:每当value值改变时,input事件都会被出发;change事件仅当value值被提交时触发。
上一篇:淘宝首页源码下载
下一篇:没有了!