How to change the style of alert box?

后端 未结 13 2116
一生所求
一生所求 2020-11-22 01:49

I need to change the style of the \"OK\" Button in an alert box.

13条回答
  •  孤城傲影
    2020-11-22 02:30

    You need to create your own alert box like this:

    function jAlert(text, customokay){
    	document.getElementById('jAlert_content').innerHTML = text;
        document.getElementById('jAlert_ok').innerHTML = customokay;
        document.body.style.backgroundColor = "gray";
        document.body.style.cursor="wait";
    }
    
    
    
    jAlert("Stop! Stop!", "Okay!");
    #jAlert_table, #jAlert_th, #jAlert_td{
        border: 2px solid blue;
        background-color:lightblue;
        border-collapse: collapse;
        width=100px;
    }
    
    #jAlert_th, #jAlert_td{
        padding:5px;
        padding-right:10px;
        padding-left:10px;
    }
    
    #jAlert{
        /* Position fixed */
        position:fixed;
        /* Center it! */
        top: 50%;
        left: 50%;
        margin-top: -50px;
        margin-left: -100px;
    }

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    TEXT

    The js portion gets the element in the HTML to create the alert box, then deletes it after the user clicks ok.

    You can call the alert using jAlert("Custom Text", "Ok!");

提交回复
热议问题