HTML
x
1
2
<html>
3
<head>
4
<style>
5
.city{
6
background:orange;
7
padding:10px;
8
color:white;
9
}
10
</style>
11
</head>
12
<body>
13
14
<h3> JavaScript দিয়ে ক৕লাস নেম অন৕সারে ব৕যাকগ৕রাউন৕ড পরিবর৕তন </h3>
15
<h4>নিচের বাটনে ক৕লিক কর৕ন</h4>
16
17
<button onclick="myFunction()">Change color</button>
18
19
<h2 class="city">London</h2>
20
<p>London is the capital of England.</p>
21
22
<h2 class="city">Paris</h2>
23
<p>Paris is the capital of France.</p>
24
25
<h2 class="city">Tokyo</h2>
26
<p>Tokyo is the capital of Japan.</p>
27
28
<script>
29
function myFunction() {
30
var x = document.getElementsByClassName("city");
31
for (var i = 0; i < x.length; i++) {
32
x[i].style.background = "green";
33
}
34
}
35
</script>
36
37
</body>
38
</html>
39
CSS
1
1
JavaScript
1
1
Output: