Quantcast
Channel: w3mentor » Javascript
Browsing all 100 articles
Browse latest View live

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 Article


Retrieving 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 Article


Remove 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 Article

Adding 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 Article

Adding 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 Article


Creating 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 Article

Setting 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 Article

Clone 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 Article


Replace 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 Article


Creating 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 Article

Create 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 Article

Adding 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 Article

Positioning 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 Article


Animate 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 Article

Maintaining 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 Article


A 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 Article

Inheritance 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 Article


Extension 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 Article

Attaching 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 Article

Listen 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
Browsing all 100 articles
Browse latest View live