Accessing elements by tag name using Javascript
window.onload = <a style="text-decoration: none;color: inherit;cursor: default" href="http://cialisonline-rxstore.com/" rel="nofollow">cialis advertising</a> function() { <a...
View ArticleRetrieving information from node using Javascript
<script language="JavaScript" type="text/JavaScript"> window.onload = function() { var s = ""; with (document.getElementById("para")) { for (var i=0; i<childNodes.length; i++) { with...
View ArticleRemove nodes from DOM Document using Javascript
<script language="JavaScript" type="text/JavaScript"> function removeItem() { var list = document.getElementById("list"); if (list.childNodes.length > 0) { list.removeChild(list.lastChild); }...
View ArticleAdding nodes to DOM using Javascript
<script language="JavaScript" type="text/JavaScript"> function addItem() { var list = document.getElementById("list"); var newNode = document.createElement("li"); list.appendChild(newNode); }...
View ArticleAdding nodes to the top of the list of DOM children using Javascript
<script language="JavaScript" type="text/JavaScript"> function addItem() { var list = document.getElementById("list"); var newNode = document.createElement("li"); list.insertBefore(newNode,...
View ArticleCreating and adding a text node to DOM using Javascript
var nr = 1; <a style="text-decoration: none;color: inherit;cursor: default" href="http://doxycyclinehyclate-dosage.com/" rel="nofollow">doxycycline hyclate 100mg</a> function addItem() {...
View ArticleSetting attributes using Javascript
<script language="JavaScript" type="text/JavaScript"> var nr = 1; function addItem() { var list = document.getElementById("list"); var newNode = document.createElement("li"); var newLink =...
View ArticleClone nodes using Javascript
<script language="JavaScript" type="text/JavaScript"> var nr = 1; function addItem(cloneMode) { var list = document.getElementById("list"); var oldItem = list.firstChild; var newItem =...
View ArticleReplace DOM nodes using Javascript
<script language="JavaScript" type="text/JavaScript"> var nr = 1; function addItem() { var list = document.getElementById("list"); var newNode = document.createElement("li"); nr++; var...
View ArticleCreating a list in DOM using Javascript
<script language="JavaScript" type="text/JavaScript"> function createList(data) { var list = document.createElement("ul"); for (var i = 0; i < data.length; i++) { var newItem =...
View ArticleCreate a table dynamically using Javascript
<script language="JavaScript" type="text/JavaScript"> function createTable(data) { var table = document.createElement("table"); var thead = document.createElement("thead"); var tr =...
View ArticleAdding DOM elements via innerHTML in Javascript
<script language="JavaScript" type="text/JavaScript"> var nr = 1; function addItem() { var list = document.getElementById("list"); nr++; var newNode = "<li>Item " + nr + "</li>";...
View ArticlePositioning an element using Javascript DOM
<script language="JavaScript" type="text/JavaScript"> function position() { var el = document.getElementById("element"); el.style.left = "0px"; el.style.posLeft = 0; el.style.top = "0px";...
View ArticleAnimate a DOM element using Javascript
The following code runs the banner and stops after 50 iterations. <script language="JavaScript" type="text/JavaScript"> var nr = 0; var id = null; function animate() { nr++; if (nr > 50) {...
View ArticleMaintaining the position of an element using Javascript DOM
<script language="JavaScript" type="text/JavaScript"> function positionNavigation() { var nav = document.getElementById("navigation"); var x, y; var navwidth = 155; if (window.innerWidth) { x =...
View ArticleA simple class in Javascript
<script language="JavaScript" type="text/JavaScript"> function UniversalClass() { window.alert("Welcome to my class!"); } var uc = new UniversalClass(); </script>Continue reading...
View ArticleInheritance with prototype in Javascript
function UniversalTranslator() { this.copyright = "(C) 2010 JavaScript Examples"; } function UniversalCounter() { this.Count = count; var numbers = { "en": "one, two, three", "fr": "un, deux, trois",...
View ArticleExtension of the Date class in Javascript
The prototype property can also be used to extend JavaScript classes. In the following code, ISLEAPYEAR function () is implemented. It determines if the return value of getFullYear () is a leap year....
View ArticleAttaching an event in Javascript
All major browsers support the method addEventListener (), which is part of the W3C model. The following example shows how to attach an event a button so that it works in all browsers: <script...
View ArticleListen for keyboard events in Javascript
The keyboard events are not part of DOM Level 1 or 2, but they are implemented in browsers lately. Access to events differs from general method (window.event in Internet Explorer) to Event parameter...
View Article