image popup js close button

Solutions on MaxInterview for image popup js close button by the best coders in the world

showing results for - "image popup js close button"
Romain
20 Jan 2019
1$('.menu').mouseover(function(e) {
2    console.log(e);
3    var href = $(this).attr('href');
4    var popup = $('<div id="myPopup"></div>');
5
6    var image = $('<img id="image" src="' + href + '"/>');
7    popup.append(image);
8
9    var text = $('<p>My Text</p>');
10    popup.append(text);
11
12    var closeBtn = $('<button>X</button>');
13    popup.append(closeBtn);
14
15    popup.css('top', e.pageY + offsetY).css('left', e.pageX + offsetX);
16    popup.append('body');
17
18    closeBtn.button().click(function() {
19        $('#myPopup').remove();
20    });
21}, function(e) {
22    // do nothing
23});