The most viewed posts

Registry Reviver

How to clean up Windows Computer

About Desktop Icons in Windows Computer

Web Development Services

How to make a computer secure and run faster

Driver Booster

Myanmar font and keyboard for Windows

CCleaner

Advanced System Care

some (JavaScript Array Method)

The most viewed items

Desktop Hard Disk

Dell Inspiron 5559

HP ProBook 430

SONY Playstation Portable

Laptop RAM

External Hard Disk

Laptop

ZilaStar ICT Dec 6 2019, 17:04:37
Category : JavaScript Tutorials

Accessing Elements

// 1. Access Element By Id
/*
function tnwFun(){
var txt = "<b>Welcome to TNW(Web Service & ICT Solutions)</b><br /><br />TNW Provides The Best ICT Solutions For Your Business By The Reasonable Price.";
document.getElementById("tnwId").innerHTML = txt;
}*/

// 2. Access Elements By ClassName

/*
function tnwBlue(){
var i;
var x = document.getElementsByClassName("tnwPage");
for(i = 0; i < x.length; i++){
x[i].style.backgroundColor = "blue";
x[i].style.color = "white";
}
}

function tnwRed(){
var i;
var x = document.getElementsByClassName("tnwPage");
for(i = 0; i < x.length; i++){
x[i].style.backgroundColor = "red";
x[i].style.color = "white";
}
} */

// 3. Access Elements By Name
/*
function tnwBlue(){
var i;
var x = document.getElementsByName("tnwName");
for(i = 0; i < x.length; i++){
x[i].style.backgroundColor = "blue";
x[i].style.color = "white";
}
}

function tnwRed(){
var i;
var x = document.getElementsByName("tnwName");
for(i = 0; i < x.length; i++){
x[i].style.backgroundColor = "red";
x[i].style.color = "white";
}
} */

// 4. Access Elements By tagName
/*
function tnwFun(){
var i;
var x = document.getElementsByTagName("li");
for(i = 0; i < x.length; i++){
x[i].style.color = "red";
}
}*/

// 5. Access Element By CSS Selector

function tnwFun(){
var i;
var x = document.querySelectorAll(".tnwClass");
for (i = 0; i < x.length; i++){
x[i].style.color = "red";
}
}

  • Comments:

    No comment to show.

    To Contact
    Available Services
    Terms and Conditions