-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
60 lines (42 loc) · 1.59 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* $(document).ready(function(){
//quando o documento html estiver pronto (ready) chamará a função
console.log(document.querySelector('header button'))
console.log($('#btn-cancel'))
document.querySelector('header button').addEventListener('click', function(){
})
$('header button').click(function(){
$('form').slideDown();
})
$('#btn-cancel').click(function(){
$('form').slideUp();
})
$('form').on('submit', function(e){
console.log('submit');
e.preventDefault();
})
}) */
//jquery formato $(document) -- $('elemento'), enquanto querySelector seria document.querySelector('')
$(document).ready(function(){
$('header button').click(function(){
$('form').slideDown();
})
$('#btn-cancel').click(function(){
$('form').slideUp();
})
$('form').on('submit', function(e){
e.preventDefault();
const newImageAdress = $('#new-image-adress').val();
const newItem = $('<li style="display: none"></li>');
$(`<img src="${newImageAdress}" />`).appendTo(newItem); //insere o endereço dentro dos lis do new item
$(`
<div class="overlay-image-link">
<a href="${newImageAdress}" target="_blank" title="View image in full size">
View image in full size
</a>
</div>
`).appendTo(newItem);
$(newItem).appendTo('ul');
$(newItem).fadeIn(1000); //1000ms = 1 segundo
$('#new-image-adress').val('');
})
})