<div id="ids">点击
<p id="ip">段落</p>
</div>
<button id="dj">点击</button>
<!-- <input type="text" id="inp"> -->
</body>
<script src="./jquery-3.4.1.js"></script>
<!-- <script></script> -->
<script>
// window.onload=function(){
// document.getElementById(‘ids‘).onclick=function(){
// alert(‘点击‘)
// }
// }
// document.getElementById(‘inp‘).onblur=function(){
// alert(‘失去焦点‘)
// }
// document.getElementById(‘inp‘).onfocus=function(){
// alert(‘获取焦点‘)
// }
// 添加新元素
// var p=document.createElement(‘p‘)
// var nod=document.createTextNode(‘新段落‘)
// p.appendChild(nod)
// document.getElementById(‘ids‘).appendChild(p)
// 删除元素
// document.getElementById(‘dj‘).onclick=function(){
// var parent=document.getElementById(‘ids‘)
// var chi=document.getElementById(‘ip‘)
// parent.removeChild(chi)
// }
// 替换
var i=1
var t= setInterval(function(){
if(i==1){
document.getElementById(‘img‘).src=‘./641.jpg‘;
}else{
document.getElementById(‘img‘).src=‘./642.jpg‘;
}
if(i==2){
i=0
}
i++
},1000)