H
H
hollanditkzn2018-02-22 11:33:25
JavaScript
hollanditkzn, 2018-02-22 11:33:25

How can I display a div on click from a modal window?

I have an implementation of my own alert and I get nothing when I click on the button. Here is something that should come out https://jsfiddle.net/hollanditkzn/szqpcorx/1/
But I placed this code in my modal window

$('body').on('click', '.alert-confirm', function (e) {
        e.preventDefault();
        console.log('Hello world');
        let div = document.createElement('div');
        div.style.cssText = "text-align:" +
            "center;padding:10px;" +
            "position:fixed;" +
            "width:200px;" +
            "height:40px;" +
            "bottom:50%;" +
            "right:50%;" +
            "margin-right:-100px;" +
            "margin-bottom:-20px;";
        console.log(div);
        div.onclick = function (e) {
            let t = e ? e.target : window.event.srcElement;
            if(t === 'INPUT'){
                t.value === 'Да' && alert('Да');
                this.parentNode.removeChild(this);
            }
        };
        div.innerHTML='<div>'+$('.alert-confirm').data('title') +'<br/>'+$('.alert-confirm').data('message')+'</div><input type="button" value="Да"><input type="button" value="Нет">';

And this code console.log(div);displays, and what is not below. How can I be here?
Can I provide the code on GitHub?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stimulate, 2018-02-22
@hollanditkzn

Try
$('body').on('click', 'div', function (e) {...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question