The nodeValue property is used to get the node value. You need to specify the node.ExampleYou can try to run the following code to learn how to get nodeValue property.Live Demo Get the node value Demo Button Text var val = document.getElementsByTagName("BUTTON")[0]; var res = val.childNodes[0].nodeValue; document.write("Node Value: "+res);
The nodeName property in JavaScript is used to specify the name of a node.ExampleYou can try to run the following code to learn how to implement a nodeName property in JavaScript.Live Demo Tutorials Demo Content document.getElementById("id3").innerHTML = document.getElementById("id1").nodeName; document.getElementById("id4").innerHTML = document.getElementById("id2").nodeName;
The onfocus event is triggered when element gets focus. You can try to run the following code to learn how to implement onfocus event in JavaScript.Example Write below: function newFunc(x) { x.style.background = "blue"; }
The blur event triggers when object lose focus. You can try to run the following code to learn how to implement onblur event in JavaScript.Example Write below: function newFunc(a) { a.style.background = "green"; }
The unload event trigger when you unload (or refresh) a page. You can try to run the following code to learn how to implement onunload event in JavaScript.Example Close the page and see what happens! This event may give unexpected results. function newFunc() { alert("Thank you!"); }
Use the document.title property to set the title of the document in JavaScript.ExampleYou can try to run the following code to implement document.title property in JavaScript.Live Demo Demo Title var x = document.title; document.write("Our Title: "+x);
The resize event is triggered when the window is resized. Use window.outerWidth and window.outerHeight event in JavaScript to get the size of windows when the browser is resized.ExampleYou can try to run the following code to work with an onresize event in JavaScript. function resizeFunction() { var val = "Window Width=" + window.outerWidth + ", Window Height=" + window.outerHeight; document.getElementById("test").innerHTML = val; } Resize browser window and check the window (browser window) height and width again.
The onscroll event occurs when scrollbar is being scrolled for an element. You can try to run the following code to learn how to implement onscroll event in JavaScript.Example div { border: 2px solid blue; width: 300px; height: 100px; overflow: scroll; } This is ... Read More
The onpagehide event triggers in JavaScript when a user leaves the page and decides to move to another. Some examples include age refresh, a link is clicked, etc.ExampleYou can try the following code to learn how to implement onpagehide event in JavaScript. Close the page and see what happens! function newFunc() { alert("Thank you!"); }
If you want to trigger an event before the document is loaded, then use the onbeforeunload event.ExampleYou can try to run the following code to learn how to implement onbeforeunload event in JavaScript. Click to open Qries function myFunction() { return "Working with onbeforeunload event"; }
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP