-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.html
67 lines (56 loc) · 2.27 KB
/
javascript.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
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
<!DOCTYPE html>
<html>
<header>
<title>Javascript.html</title>
</header>
<body>
<style>
.p {
text-align: center;
}
</style>
<div class="p">
<p id="text"> Samchel is a good boy</p>
<!-- <button onclick="alert('hello!')">click me!</button> -->
<button id="mybutton">change me</button>
<p id="secondP">bolaji is ...</p>
<button id="SecondB">click me</button>
<p id="emptyP"></p>
<button id="Pempty">click me</button>
<p id="textcolor">change color</p>
<button id="style">click me</button>
</div>
<script type="text/Javascript">
// alert('page is loaded!!');
// changing content of our page in html by using javascript.
// document.getElementById('text').innerHTML = "Intelligent and Good";
// changing my button
//changing my paragraph content when u click on (change me) to (great guy)
document.getElementById('mybutton').onclick = function() {
document.getElementById('text').innerHTML = 'great guy!'
};
// changing website content by adding a javascrpit to my second Paragraph
document.getElementById('SecondB').onclick = function() {
document.getElementById('secondP').innerHTML = 'I Think ' + document.getElementById('secondP').innerHTML +'Great guy!'
};
// including to our Paragraph by using javascript
document.getElementById('Pempty').onclick = function() {
document.getElementById('emptyP').innerHTML =' <h1>Hi Dear!</h1>'
};
// javacript css
document.getElementById('style').onclick = function() {
document.getElementById('textcolor').style.color = 'red'
document.getElementById('textcolor').style.fontSize = '50px'
};
// Array
var myArray = new Array();
myArray[0] = 'orange';
myArray[1] = 'Apple';
// alert(myArray[0]);
mytweets = ['i love ade', 'i love iyanu','i love vicky']
//Array functions
mytweets.push('i love feyi') //.push means add a text inside Array at the end of the text.
mytweets.splice(0, 2, 'I am choosen one'); //.splice is to remove or add a text inside Array.
console.log(mytweets);
</script>
</body>