-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetingHtmlValues.html
More file actions
124 lines (111 loc) · 4.52 KB
/
Copy pathgetingHtmlValues.html
File metadata and controls
124 lines (111 loc) · 4.52 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
<!-- Popup plugins -->
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Comic+Neue|Gotu|Montserrat|Roboto&display=swap" rel="stylesheet">
<style>
body{
background: url('https://images.pexels.com/photos/1714205/pexels-photo-1714205.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940');
}
.img-bird{
width: 550px;
min-width: 200px;
max-width: 900px;
position: relative;
}
h1{
font-family: 'Roboto', sans-serif;
}
button{
font-family: 'Gotu', sans-serif;
}
.city{
width: 300px;
margin: 0 auto;
}
</style>
<link rel="stylesheet" href="animate.css">
<title>Getting HTML Content : Jquery</title>
</head>
<body>
<div class="bg-dark">
<h1 class="p-4 text-center text-white animated bounceInDown">Getting HTML Content : Jquery</h1>
</div>
<div class="container text-center">
<button class="btn btn-dark btn-lg mt-4 getText animated fadeInUp delay-1s"> Click to Get Text</button>
<button class="btn btn-light btn-lg mt-4 getHtml ml-3 animated fadeInUp delay-1s">Click to get HTML</button>
<br>
<input type="text" name="city" id="city" class="form-control animated fadeInUp delay-2s city my-5" placeholder="Enter city name here...">
<button class="btn btn-info btn-lg getcity ml-3 animated fadeInUp delay-2s">Get City</button>
<a href="#" class="btn btn-primary btn-lg google ml-3 animated fadeInUp delay-2s">Google</a>
<br>
<br>
<a href="#" class="btn btn-warning btn-lg changeH1 ml-3 animated fadeInUp delay-3s">Change Heading</a>
</div>
<script>
$('.changeH1').click(()=>{
$('h1').text((i, old)=>{
return old + 'Added via JQ'
});
})
function animateCSS(element, animationName, callback) {
const node = document.querySelector(element)
node.classList.add('animated', animationName)
function handleAnimationEnd() {
node.classList.remove('animated', animationName)
node.removeEventListener('animationend', handleAnimationEnd)
if (typeof callback === 'function') callback()
}
node.addEventListener('animationend', handleAnimationEnd)
}
$(()=>{
$('.getText').click(()=>{
swal("Text is : " + $('h1').text());
})
$('.getHtml').click(()=>{
swal("Html is : " + $('h1'));
console.log($('h1'))
})
$('.google').click(()=>{
swal({
title: "Are you sure?",
text: "This will redirect you to goole.com",
buttons: {
cancel: 'cancel',
open: {
text: 'open',
value: 'open'
}
},
})
.then((value) => {
if (value == 'open') {
window.location.replace("https://www.google.com");
} else {
console.log('hello')
}
});
})
$('.getcity').click(()=>{
if($('.city').val() != ''){
swal('Your City : '+$('.city').val());
$('.city').val('')
}else{
swal('Please Enter City Name').then(value =>{
animateCSS('.city','shake');
});
}
})
})
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.min.js"></script>
</body>
</html>