-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselectors.html
40 lines (40 loc) · 1.19 KB
/
selectors.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jquery Selectors</title>
<!-- link to jquery cdn -->
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js">
</script>
<script>
// when dom is ready do things in this function
$(document).ready(function(){
$('#sh').click(function(){ // select by id with # which is same used by css id
$('.my-selector').hide(); // select by class . which is same used by css class
});
$('#ih').click(function(){
$('#my-id').hide();
});
$('#is').click(function(){
$('#my-id').show();
});
$('#ss').click(function(){
$('.my-selector').show();
});
});
</script>
</head>
<body>
<h1>Testing Selectors</h1>
<p class="my-selector">I'm my selectors class</p>
<p class="my-selector">I'm also my selectors class</p>
<p id="my-id">I'm a id</p>
<button id="sh">Selector Hide</button>
<button id="ss">Selector Show</button>
<button id="is">id Show</button>
<button id="ih">id hide</button>
</body>
</html>