用console 控制台操作網頁事件


 打開瀏覽器控制台:

var js = window.document.createElement('script');
js.setAttribute('src', 'https://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js');
js.onload = function() {
    $('#item1').html('test html')
};
window.document.head.appendChild(js);

 

 

 

 

 js面試題目:https://www.cnblogs.com/7qin/p/9677928.html

 

 

 

.

js  message()

var appendHTML=function(el, html){
    var divTemp = document.createElement("div"), nodes = null
        // 文檔片段,一次性append,提高性能
        , fragment = document.createDocumentFragment();
    divTemp.innerHTML = html;
    nodes = divTemp.childNodes;
    for (var i=0, length=nodes.length; i<length; i+=1) {
       fragment.appendChild(nodes[i].cloneNode(true));
    }
    el.appendChild(fragment);
    // 據說下面這樣子世界會更清凈
    nodes = null;
    fragment = null;
};

function showMessage(message,type,time) {
        let str = ''
        switch (type) {
            case 'success':
                str = '<div class="success-message animation" style="opacity:0;width: 300px;height: 40px;text-align: center;background-color:#daf5eb;;color: rgba(59,128,58,0.7);position: fixed;left: 50%;top: 30%;transform:translate(-50%,-50%);line-height: 40px;border-radius: 5px;z-index: 9999">\n' +
                    '    <span class="mes-text">'+message+'</span></div>'
                break;
            case 'error':
                str = '<div class="error-message animation" style="opacity:0;width: 300px;height: 40px;text-align: center;background-color: #f5f0e5;color: rgba(238,99,99,0.8);position: fixed;left: 50%;top: 30%;transform:translate(-50%,-50%);line-height: 40px;border-radius: 5px;;z-index: 9999">\n' +
                    '    <span class="mes-text">'+message+'</span></div>'
        }

str='<style>.animation{animation:mymove 3s forwards ;-webkit-animation:mymove 3s forwards;}@keyframes mymove{0%{opacity:0;}50%{opacity:1;}100%{opacity:0;}}@-webkit-keyframes mymove{0%{opacity:1;}50%{opacity:0.5;}100%{opacity:0;}}</style>'+str;
        appendHTML( document.querySelector('body') , str );
        setTimeout(function () {
            document.querySelector('body').removeChild(document.querySelector('.'+type+'-message'));
        },time)
    }

showMessage('添加成功','success',2000)
View Code

 

 jump

 

第 1 張

 

 

 

 

 

第 2 張

 

 

 

第 3 張

 

 

 

 

 

 

第 4 張

 

 

 

第 5 張

 

 

 

 

 

 

第 6 張

 

 

 

 

 

 

第 7 張

 

 

 

 

 

 

第 8 張

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM