harry js1
console.log("hello world");
let a = window;
console.log(a);
let a = window.document;
a = prompt('this is warning. type your name ');
console.log(a);
a = confirm('are you sure you want to change it ');
console.log(a);
b = window.innerHeight;
a = window.innerWidth;
a= window.scrollX;
b = window.scrollY;
a= location;
a = location.toString();
a =window.history;
console.log(a,b);
console.log('new');
a= document;
a = document.forms;
a = document.forms[0];
a= document.all;
Array.forms(a).forEach(function(element) {
console.log(element);
});
let element = document.getElementById('heading');
// element.style.color = 'red';
element.innerText = 'biplav is a good boy';
element.innerHTML = '<b>ok google</b>';
// element = element.className;
element = element.parentNode;
element = element.childNodes;
element.innerText = 'biplav is a good boy';
console.log(element);
// console.log('kkk');
console.log('single element selector');
let sel = document.querySelector('div');
sel.style.color = 'green';
sel = document.querySelector('head');
console.log(sel);
console.log('multiple element selector');
//let r = document.getElementsByClassName('container');
r= document.getElementsByTagName('div');
console.log(r);
Array.from(r).forEach(Element =>{
console.log(Element);
Element.style.color = 'blue';
});
// console.log(r[0].getElementsByClassName('class'));
HTML
<div class="container">
<h1 id="heading">welcome to js</h1>
<div id="myfirst" class="class" id="first">child 1</div>
<div class="class">child 2</div>
<div class="class">child 3</div>
<div class="class">child 4</div>
<form action="none.html" method = "POST">
Enter Some text: <input type="text" name="hello" id="">
<input type="button" value="submit">
</form>
</div>
</body>
<script src="jp/jp.js"></script>
</html>
Comments
Post a Comment