首页 > 其他 > 详细

添加删除元素 事件

时间:2020-05-06 21:20:32      阅读:52      评论:0      收藏:0      [点我收藏+]


    <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)

添加删除元素 事件

原文:https://www.cnblogs.com/z242643/p/12837379.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!