javascript onclick create(element) div viz popup box

前端 未结 4 1083
天涯浪人
天涯浪人 2021-01-15 01:51

I\'m trying to make a pop up box, which gets invoked on clicking a button, this is what I\'ve got so far.. http://jsfiddle.net/WGPhG/2/

4条回答
  •  再見小時候
    2021-01-15 02:00

    Try This

    function popUp(){
        var popup = document.createElement('div');
        popup.className = 'popup';
        popup.id = 'test';
        var cancel = document.createElement('div');
        cancel.className = 'cancel';
        cancel.setAttribute('onClick', 'document.getElementById("test").parentNode.removeChild('+popup +');')
    
        popup.innerHTML = "This is a test message";
        document.body.appendChild(popup);
        popup.appendChild(cancel);
     }
    

提交回复
热议问题